Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions oxlint.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import type { OxlintConfig } from "oxlint";
import { defineConfig } from "oxlint";

const disabledRules = [
// Temporarily disabled
"eslint/prefer-named-capture-group",
"unicorn/import-style",

"eslint/arrow-body-style",
"eslint/capitalized-comments",
"eslint/class-methods-use-this",
Expand Down Expand Up @@ -33,6 +29,7 @@ const disabledRules = [
"eslint/no-use-before-define",
"eslint/no-void",
"eslint/prefer-destructuring",
"eslint/prefer-named-capture-group",
"eslint/sort-imports",
"eslint/sort-keys",
"eslint/sort-vars",
Expand Down
2 changes: 1 addition & 1 deletion packages/app-talonjs/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as talon from "talon";
import talon from "talon";
Comment thread
AndreasArvidsson marked this conversation as resolved.
import type { RunMode } from "@cursorless/lib-common";
import { activate as activateCore } from "@cursorless/lib-talonjs-core";

Expand Down
8 changes: 4 additions & 4 deletions packages/app-vscode/src/InstallationDependencies.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import glob from "fast-glob";
import * as vscode from "vscode";
import vscode from "vscode";
import { isWindows } from "@cursorless/lib-node-common";
import { COMMAND_SERVER_EXTENSION_ID } from "@cursorless/lib-vscode-common";

Expand Down
28 changes: 14 additions & 14 deletions packages/app-vscode/src/ReleaseNotes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sinon from "sinon";
import { fake, restore, assert, match } from "sinon";
import type { ExtensionContext, Uri } from "vscode";
import type { MessageType, Messages } from "@cursorless/lib-common";
import { asyncSafety } from "@cursorless/lib-common";
Expand Down Expand Up @@ -154,7 +154,7 @@ const testCases: TestCase[] = [

suite("release notes", () => {
teardown(() => {
sinon.restore();
restore();
});

for (const { input, expectedOutput } of testCases) {
Expand Down Expand Up @@ -192,36 +192,36 @@ async function runTest(input: Input, expectedOutput: Output) {
await new ReleaseNotes(vscodeApi, extensionContext, messages).maybeShow();

if (expectedOutput.storedVersion === false) {
sinon.assert.notCalled(update);
assert.notCalled(update);
} else {
sinon.assert.calledOnceWithExactly(
assert.calledOnceWithExactly(
update,
VERSION_KEY,
expectedOutput.storedVersion,
);
}

if (expectedOutput.showedMessage) {
sinon.assert.calledOnceWithExactly(
assert.calledOnceWithExactly(
showMessage,
sinon.match.any,
match.any,
"releaseNotes",
sinon.match.any,
sinon.match.any,
match.any,
match.any,
);

if (expectedOutput.openedUrl) {
sinon.assert.calledOnce(openExternal);
assert.calledOnce(openExternal);
} else {
sinon.assert.notCalled(openExternal);
assert.notCalled(openExternal);
}
} else {
sinon.assert.notCalled(showMessage);
assert.notCalled(showMessage);
}
}

function getFakes(input: Input) {
const openExternal = sinon.fake.resolves<[Uri], Promise<boolean>>(true);
const openExternal = fake.resolves<[Uri], Promise<boolean>>(true);
const vscodeApi = {
window: {
state: {
Expand All @@ -233,7 +233,7 @@ function getFakes(input: Input) {
},
} as unknown as VscodeApi;

const update = sinon.fake<[string, string], Promise<void>>();
const update = fake<[string, string], Promise<void>>();
const extensionContext = {
globalState: {
get() {
Expand All @@ -248,7 +248,7 @@ function getFakes(input: Input) {
},
} as unknown as ExtensionContext;

const showMessage = sinon.fake.resolves<
const showMessage = fake.resolves<
[MessageType, string, string, ...string[]],
Promise<string | undefined>
>(input.pressedButton ? WHATS_NEW : undefined);
Expand Down
2 changes: 1 addition & 1 deletion packages/app-vscode/src/ReleaseNotes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as semver from "semver";
import semver from "semver";
import type { ExtensionContext } from "vscode";
import { URI } from "vscode-uri";
import type { Messages } from "@cursorless/lib-common";
Expand Down
2 changes: 1 addition & 1 deletion packages/app-vscode/src/StatusBarItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as vscode from "vscode";
import vscode from "vscode";

const DEFAULT_TEXT = "$(cursorless-icon) Cursorless";

Expand Down
4 changes: 2 additions & 2 deletions packages/app-vscode/src/VscodeSnippets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { open } from "node:fs/promises";
import { join } from "node:path";
import path from "node:path";
import type { IDE, TextEditor } from "@cursorless/lib-common";
import type { Snippets } from "@cursorless/lib-engine";
import { isEexistError } from "@cursorless/lib-node-common";
Expand All @@ -11,7 +11,7 @@ export class VscodeSnippets implements Snippets {
snippetName: string,
directory: string,
): Promise<TextEditor> {
const snippetPath = join(directory, `${snippetName}.snippet`);
const snippetPath = path.join(directory, `${snippetName}.snippet`);
await createNewFile(snippetPath);
return this.ide.openTextDocument(snippetPath);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-vscode/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as vscode from "vscode";
import vscode from "vscode";
import { CURSORLESS_ORG_URL, DOCS_URL } from "@cursorless/lib-common";

export const showDocumentation = () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/app-vscode/src/createVscodeIde.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as crypto from "node:crypto";
import * as os from "node:os";
import * as path from "node:path";
import crypto from "node:crypto";
import os from "node:os";
import path from "node:path";
import type { ExtensionContext } from "vscode";
import { FakeFontMeasurements } from "./ide/vscode/hats/FakeFontMeasurements";
import { FontMeasurementsImpl } from "./ide/vscode/hats/FontMeasurementsImpl";
Expand Down
4 changes: 2 additions & 2 deletions packages/app-vscode/src/ide/vscode/VscodeCapabilities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as semver from "semver";
import * as vscode from "vscode";
import semver from "semver";
import vscode from "vscode";
import type {
Capabilities,
CommandCapabilityMap,
Expand Down
2 changes: 1 addition & 1 deletion packages/app-vscode/src/ide/vscode/VscodeClipboard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as vscode from "vscode";
import vscode from "vscode";
import type { Clipboard } from "@cursorless/lib-common";

export class VscodeClipboard implements Clipboard {
Expand Down
4 changes: 2 additions & 2 deletions packages/app-vscode/src/ide/vscode/VscodeConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as os from "node:os";
import * as vscode from "vscode";
import os from "node:os";
import vscode from "vscode";
import type {
Configuration,
ConfigurationScope,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pickBy } from "lodash-es";
import * as vscode from "vscode";
import vscode from "vscode";
import type {
HatStyleInfo,
HatStyleMap,
Expand Down
2 changes: 1 addition & 1 deletion packages/app-vscode/src/ide/vscode/VscodeEvents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as vscode from "vscode";
import vscode from "vscode";
import type {
Disposable,
Event,
Expand Down
26 changes: 16 additions & 10 deletions packages/app-vscode/src/ide/vscode/VscodeFileSystem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isAbsolute, join } from "node:path";
import * as vscode from "vscode";
import path from "node:path";
import vscode from "vscode";
import type {
Disposable,
FileSystem,
Expand All @@ -19,8 +19,11 @@ export class VscodeFileSystem implements FileSystem {
private readonly runMode: RunMode,
private readonly cursorlessDir: string,
) {
this.cursorlessTalonStateJsonPath = join(this.cursorlessDir, "state.json");
this.cursorlessCommandHistoryDirPath = join(
this.cursorlessTalonStateJsonPath = path.join(
this.cursorlessDir,
"state.json",
);
this.cursorlessCommandHistoryDirPath = path.join(
this.cursorlessDir,
"commandHistory",
);
Expand Down Expand Up @@ -60,24 +63,27 @@ export class VscodeFileSystem implements FileSystem {
}
}

private resolveBundledPath(path: string) {
if (isAbsolute(path)) {
private resolveBundledPath(bundledPath: string) {
if (path.isAbsolute(bundledPath)) {
if (this.runMode !== "development") {
throw new Error(
"Absolute paths are not supported outside of development mode",
);
}

return vscode.Uri.file(path);
return vscode.Uri.file(bundledPath);
}

return vscode.Uri.joinPath(this.extensionContext.extensionUri, path);
return vscode.Uri.joinPath(this.extensionContext.extensionUri, bundledPath);
}

public watchDir(path: string, onDidChange: PathChangeListener): Disposable {
public watchDir(
dirPath: string,
onDidChange: PathChangeListener,
): Disposable {
// FIXME: Support globs?
const watcher = vscode.workspace.createFileSystemWatcher(
new vscode.RelativePattern(path, "**"),
new vscode.RelativePattern(dirPath, "**"),
);

watcher.onDidChange(onDidChange);
Expand Down
2 changes: 1 addition & 1 deletion packages/app-vscode/src/ide/vscode/VscodeFold.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as vscode from "vscode";
import vscode from "vscode";
import type { Range } from "@cursorless/lib-common";
import type { VscodeIDE } from "./VscodeIDE";
import type { VscodeTextEditor } from "./VscodeTextEditor";
Expand Down
11 changes: 3 additions & 8 deletions packages/app-vscode/src/ide/vscode/VscodeHighlights.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ExtensionContext } from "vscode";
import * as vscode from "vscode";
import { Range } from "vscode";
import type {
CharacterRange,
GeneralizedRange,
Expand Down Expand Up @@ -65,18 +65,13 @@ export class VscodeHighlights {
tokenDecorationType,
tokenRanges.map(
({ start, end }) =>
new vscode.Range(
start.line,
start.character,
end.line,
end.character,
),
new Range(start.line, start.character, end.line, end.character),
),
);

editor.vscodeEditor.setDecorations(
lineDecorationType,
lineRanges.map((range) => new vscode.Range(range.start, 0, range.end, 0)),
lineRanges.map((range) => new Range(range.start, 0, range.end, 0)),
);
}
}
29 changes: 16 additions & 13 deletions packages/app-vscode/src/ide/vscode/VscodeIDE.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { pull } from "lodash-es";
import { v4 as uuid } from "uuid";
import type { ExtensionContext, WorkspaceFolder } from "vscode";
import * as vscode from "vscode";
import { window, workspace } from "vscode";
import type {
ExtensionContext,
WorkspaceFolder,
TextEditor as VsTextEditor,
} from "vscode";
import { commands, window, workspace } from "vscode";
import type {
Disposable,
EditableTextEditor,
Expand Down Expand Up @@ -58,7 +61,7 @@ export class VscodeIDE implements IDE {
this.highlights = new VscodeHighlights(extensionContext);
this.flashHandler = new VscodeFlashHandler(this, this.highlights);
this.capabilities = new VscodeCapabilities();
this.editorMap = new WeakMap<vscode.TextEditor, VscodeTextEditor>();
this.editorMap = new WeakMap<VsTextEditor, VscodeTextEditor>();
}

showQuickPick(
Expand Down Expand Up @@ -124,7 +127,7 @@ export class VscodeIDE implements IDE {
}

get visibleNotebookEditors(): NotebookEditor[] {
return vscode.window.visibleNotebookEditors.map(
return window.visibleNotebookEditors.map(
(editor) => new VscodeNotebookEditorImpl(editor),
);
}
Expand All @@ -140,13 +143,13 @@ export class VscodeIDE implements IDE {
if (editor != null && !editor.isActive) {
await this.getEditableTextEditor(editor).focus();
}
await vscode.commands.executeCommand("editor.actions.findWithArgs", {
await commands.executeCommand("editor.actions.findWithArgs", {
searchString: query,
});
}

public async findInWorkspace(query: string): Promise<void> {
await vscode.commands.executeCommand("workbench.action.findInFiles", {
await commands.executeCommand("workbench.action.findInFiles", {
query,
});
}
Expand All @@ -166,14 +169,14 @@ export class VscodeIDE implements IDE {
public async showInputBox(
options?: InputBoxOptions,
): Promise<string | undefined> {
return await vscode.window.showInputBox(options);
return await window.showInputBox(options);
}

public async executeCommand<T>(
command: string,
...args: any[]
): Promise<T | undefined> {
return await vscode.commands.executeCommand(command, ...args);
return await commands.executeCommand(command, ...args);
}

public onDidChangeTextDocument(
Expand Down Expand Up @@ -213,7 +216,7 @@ export class VscodeIDE implements IDE {
}),
);

public fromVscodeEditor(editor: vscode.TextEditor): VscodeTextEditor {
public fromVscodeEditor(editor: VsTextEditor): VscodeTextEditor {
if (!this.editorMap.has(editor)) {
this.editorMap.set(editor, new VscodeTextEditor(uuid(), this, editor));
}
Expand All @@ -224,12 +227,12 @@ export class VscodeIDE implements IDE {
if (error instanceof OutdatedExtensionError) {
void this.showUpdateExtensionErrorMessage(error);
} else {
void vscode.window.showErrorMessage(getErrorMessage(error));
void window.showErrorMessage(getErrorMessage(error));
}
}

private async showUpdateExtensionErrorMessage(error: OutdatedExtensionError) {
const item = await vscode.window.showErrorMessage(
const item = await window.showErrorMessage(
error.message,
"Check for updates",
);
Expand All @@ -238,7 +241,7 @@ export class VscodeIDE implements IDE {
return;
}

await vscode.commands.executeCommand(
await commands.executeCommand(
"workbench.extensions.action.checkForUpdates",
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as vscode from "vscode";
import vscode from "vscode";
import type { Range } from "@cursorless/lib-common";
import { Selection } from "@cursorless/lib-common";
import type { VscodeTextEditor } from "./VscodeTextEditor";
Expand Down
2 changes: 1 addition & 1 deletion packages/app-vscode/src/ide/vscode/VscodeOpenLink.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as vscode from "vscode";
import vscode from "vscode";
import type { OpenLinkOptions, Range } from "@cursorless/lib-common";
import { Selection } from "@cursorless/lib-common";
import { toVscodePositionOrRange } from "@cursorless/lib-vscode-common";
Expand Down
Loading
Loading