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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type { KeyValueStore } from "./types/KeyValueStore";
import type { Messages } from "./types/Messages";
import type { QuickPickOptions } from "./types/QuickPickOptions";

export default class PassthroughIDEBase implements IDE {
export class PassthroughIDE implements IDE {
configuration: Configuration;
keyValueStore: KeyValueStore;
clipboard: Clipboard;
Expand All @@ -37,6 +37,15 @@ export default class PassthroughIDEBase implements IDE {
this.capabilities = original.capabilities;
}

setIde(original: IDE) {
this.original = original;
this.configuration = original.configuration;
this.keyValueStore = original.keyValueStore;
this.clipboard = original.clipboard;
this.messages = original.messages;
this.capabilities = original.capabilities;
}

flashRanges(flashDescriptors: FlashDescriptor[]): Promise<void> {
return this.original.flashRanges(flashDescriptors);
}
Expand Down Expand Up @@ -112,76 +121,76 @@ export default class PassthroughIDEBase implements IDE {
);
}

public get activeTextEditor(): TextEditor | undefined {
get activeTextEditor(): TextEditor | undefined {
return this.original.activeTextEditor;
}

public get activeEditableTextEditor(): EditableTextEditor | undefined {
get activeEditableTextEditor(): EditableTextEditor | undefined {
return this.original.activeEditableTextEditor;
}

public get visibleTextEditors(): TextEditor[] {
get visibleTextEditors(): TextEditor[] {
return this.original.visibleTextEditors;
}

public get visibleNotebookEditors(): NotebookEditor[] {
get visibleNotebookEditors(): NotebookEditor[] {
return this.original.visibleNotebookEditors;
}

public get cursorlessVersion(): string {
get cursorlessVersion(): string {
return this.original.cursorlessVersion;
}

public get assetsRoot(): string {
get assetsRoot(): string {
return this.original.assetsRoot;
}

public get runMode(): RunMode {
get runMode(): RunMode {
return this.original.runMode;
}

public get workspaceFolders(): readonly WorkspaceFolder[] | undefined {
get workspaceFolders(): readonly WorkspaceFolder[] | undefined {
return this.original.workspaceFolders;
}

public findInDocument(query: string, editor?: TextEditor): Promise<void> {
findInDocument(query: string, editor?: TextEditor): Promise<void> {
return this.original.findInDocument(query, editor);
}

public findInWorkspace(query: string): Promise<void> {
findInWorkspace(query: string): Promise<void> {
return this.original.findInWorkspace(query);
}

public openTextDocument(path: string): Promise<TextEditor> {
openTextDocument(path: string): Promise<TextEditor> {
return this.original.openTextDocument(path);
}

public openUntitledTextDocument(
openUntitledTextDocument(
options?: OpenUntitledTextDocumentOptions,
): Promise<TextEditor> {
return this.original.openUntitledTextDocument(options);
}

public showQuickPick(
showQuickPick(
items: readonly string[],
options?: QuickPickOptions,
): Promise<string | undefined> {
return this.original.showQuickPick(items, options);
}

public showInputBox(options?: any): Promise<string | undefined> {
showInputBox(options?: any): Promise<string | undefined> {
return this.original.showInputBox(options);
}

public getEditableTextEditor(editor: TextEditor): EditableTextEditor {
getEditableTextEditor(editor: TextEditor): EditableTextEditor {
return this.original.getEditableTextEditor(editor);
}

executeCommand<T>(command: string, ...args: any[]): Promise<T | undefined> {
return this.original.executeCommand(command, ...args);
}

public onDidChangeTextDocument(
onDidChangeTextDocument(
listener: (event: TextDocumentChangeEvent) => void,
): Disposable {
return this.original.onDidChangeTextDocument(listener);
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/ide/normalized/NormalizedIDE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import type { TextEditor } from "../../types/TextEditor";
import type FakeConfiguration from "../fake/FakeConfiguration";
import type FakeKeyValueStore from "../fake/FakeKeyValueStore";
import type { FakeIDE } from "../fake/FakeIDE";
import PassthroughIDEBase from "../PassthroughIDEBase";
import { PassthroughIDE } from "../PassthroughIDE";
import type { FlashDescriptor } from "../types/FlashDescriptor";
import type { IDE } from "../types/ide.types";
import type { QuickPickOptions } from "../types/QuickPickOptions";

export class NormalizedIDE extends PassthroughIDEBase {
export class NormalizedIDE extends PassthroughIDE {
configuration: FakeConfiguration;
keyValueStore: FakeKeyValueStore;

Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/ide/spy/SpyIDE.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { pickBy, values } from "lodash-es";
import type { GeneralizedRange } from "../../types/GeneralizedRange";
import type { TextEditor } from "../../types/TextEditor";
import PassthroughIDEBase from "../PassthroughIDEBase";
import { PassthroughIDE } from "../PassthroughIDE";
import type { FlashDescriptor } from "../types/FlashDescriptor";
import type { HighlightId, IDE } from "../types/ide.types";
import type { Message } from "./SpyMessages";
Expand All @@ -18,7 +18,7 @@ export interface SpyIDERecordedValues {
highlights?: Highlight[];
}

export class SpyIDE extends PassthroughIDEBase {
export class SpyIDE extends PassthroughIDE {
messages: SpyMessages;
private flashes: FlashDescriptor[] = [];
private highlights: Highlight[] = [];
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from "./FakeCommandServerApi";
export * from "./ide/fake/FakeIDE";
export * from "./ide/inMemoryTextDocument/InMemoryTextDocument";
export * from "./ide/normalized/NormalizedIDE";
export * from "./ide/PassthroughIDE";
export * from "./ide/spy/SpyIDE";
export * from "./ide/spy/SpyMessages";
export * from "./ide/types/Capabilities";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Range } from "../types/Range";
import { BorderStyle, type StyledRange } from "./decorationStyle.types";
import type { StyledRange } from "./decorationStyle.types";
import { BorderStyle } from "./decorationStyle.types";

export function* generateDecorationsForLineRange(
startLine: number,
Expand Down
9 changes: 5 additions & 4 deletions packages/cursorless-engine/src/CommandHistoryAnalyzer.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type {
CommandHistoryEntry,
CommandHistoryStorage,
IDE,
Modifier,
PartialPrimitiveTargetDescriptor,
ScopeType,
} from "@cursorless/common";
import { showWarning } from "@cursorless/common";
import { groupBy, map, sum } from "lodash-es";
import { canonicalizeAndValidateCommand } from "./core/commandVersionUpgrades/canonicalizeAndValidateCommand";
import { ide } from "./singletons/ide.singleton";
import { getPartialTargetDescriptors } from "./util/getPartialTargetDescriptors";
import { getPartialPrimitiveTargets } from "./util/getPrimitiveTargets";
import { getScopeType } from "./util/getScopeType";
Expand Down Expand Up @@ -116,22 +116,23 @@ function getMonth(entry: CommandHistoryEntry): string {
}

export async function analyzeCommandHistory(
ide: IDE,
commandHistoryStorage: CommandHistoryStorage,
) {
const entries = await commandHistoryStorage.getEntries();

if (entries.length === 0) {
const TAKE_ME_THERE = "Show me";
const result = await showWarning(
ide().messages,
ide.messages,
"noHistory",
"No command history entries found. Please enable the command history in the settings.",
TAKE_ME_THERE,
);

if (result === TAKE_ME_THERE) {
// FIXME: This is VSCode-specific
await ide().executeCommand(
await ide.executeCommand(
"workbench.action.openSettings",
"cursorless.commandHistory",
);
Expand All @@ -148,7 +149,7 @@ export async function analyzeCommandHistory(
),
].join("\n\n\n");

await ide().openUntitledTextDocument({ content });
await ide.openUntitledTextDocument({ content });
}

function toPercent(value: number) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cursorless-engine/src/KeyboardTargetUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class KeyboardTargetUpdater {
return;
}

this.storedTargets.set("keyboard", new CursorStage().run());
this.storedTargets.set("keyboard", new CursorStage(this.ide).run());
}

dispose() {
Expand Down
Loading
Loading