diff --git a/packages/common/ide/fake/FakeGlobalState.ts b/packages/common/ide/fake/FakeGlobalState.ts index a680128933..af2f32f8c7 100644 --- a/packages/common/ide/fake/FakeGlobalState.ts +++ b/packages/common/ide/fake/FakeGlobalState.ts @@ -8,7 +8,7 @@ export default class FakeGlobalState implements State { return this.data[key]; } - set(key: K, value: StateData[K]): Thenable { + set(key: K, value: StateData[K]): Promise { this.data[key] = value; return Promise.resolve(); } diff --git a/packages/common/ide/types/Clipboard.ts b/packages/common/ide/types/Clipboard.ts index 1590c5e6cb..5264af6797 100644 --- a/packages/common/ide/types/Clipboard.ts +++ b/packages/common/ide/types/Clipboard.ts @@ -5,13 +5,13 @@ export interface Clipboard { /** * Read the current clipboard contents as text. - * @returns A thenable that resolves to a string. + * @returns A promise that resolves to a string. */ - readText(): Thenable; + readText(): Promise; /** * Writes text into the clipboard. - * @returns A thenable that resolves when writing happened. + * @returns A promise that resolves when writing happened. */ - writeText(value: string): Thenable; + writeText(value: string): Promise; } diff --git a/packages/common/ide/types/State.ts b/packages/common/ide/types/State.ts index 9ec2fedc52..319629470c 100644 --- a/packages/common/ide/types/State.ts +++ b/packages/common/ide/types/State.ts @@ -26,5 +26,5 @@ export interface State { * @param key A string. * @param value A value. MUST not contain cyclic references. */ - set(key: K, value: StateData[K]): Thenable; + set(key: K, value: StateData[K]): Promise; } diff --git a/packages/cursorless-engine/core/updateSelections/updateSelections.ts b/packages/cursorless-engine/core/updateSelections/updateSelections.ts index 87547ba380..46f7118a25 100644 --- a/packages/cursorless-engine/core/updateSelections/updateSelections.ts +++ b/packages/cursorless-engine/core/updateSelections/updateSelections.ts @@ -146,7 +146,7 @@ function selectionInfosToSelections( */ export async function callFunctionAndUpdateSelections( rangeUpdater: RangeUpdater, - func: () => Thenable, + func: () => Promise, document: TextDocument, selectionMatrix: (readonly Selection[])[], ): Promise { @@ -165,7 +165,7 @@ export async function callFunctionAndUpdateSelections( export async function callFunctionAndUpdateRanges( rangeUpdater: RangeUpdater, - func: () => Thenable, + func: () => Promise, document: TextDocument, rangeMatrix: (readonly Range[])[], ): Promise { @@ -190,7 +190,7 @@ export async function callFunctionAndUpdateRanges( */ export async function callFunctionAndUpdateSelectionInfos( rangeUpdater: RangeUpdater, - func: () => Thenable, + func: () => Promise, document: TextDocument, selectionInfoMatrix: FullSelectionInfo[][], ) { @@ -217,7 +217,7 @@ export async function callFunctionAndUpdateSelectionInfos( */ export function callFunctionAndUpdateSelectionsWithBehavior( rangeUpdater: RangeUpdater, - func: () => Thenable, + func: () => Promise, document: TextDocument, originalSelections: SelectionsWithBehavior[], ) { diff --git a/packages/cursorless-vscode-core/ide/vscode/VscodeClipboard.ts b/packages/cursorless-vscode-core/ide/vscode/VscodeClipboard.ts index 2c3dd2e498..95556fedc6 100644 --- a/packages/cursorless-vscode-core/ide/vscode/VscodeClipboard.ts +++ b/packages/cursorless-vscode-core/ide/vscode/VscodeClipboard.ts @@ -2,11 +2,11 @@ import * as vscode from "vscode"; import { Clipboard } from "@cursorless/common"; export default class VscodeClipboard implements Clipboard { - readText(): Thenable { - return vscode.env.clipboard.readText(); + async readText(): Promise { + return await vscode.env.clipboard.readText(); } - writeText(value: string): Thenable { - return vscode.env.clipboard.writeText(value); + async writeText(value: string): Promise { + return await vscode.env.clipboard.writeText(value); } } diff --git a/packages/cursorless-vscode-core/ide/vscode/VscodeGlobalState.ts b/packages/cursorless-vscode-core/ide/vscode/VscodeGlobalState.ts index a8ba7bb9ef..73b24ee78a 100644 --- a/packages/cursorless-vscode-core/ide/vscode/VscodeGlobalState.ts +++ b/packages/cursorless-vscode-core/ide/vscode/VscodeGlobalState.ts @@ -12,7 +12,7 @@ export default class VscodeGlobalState implements State { return this.extensionContext.globalState.get(key, STATE_DEFAULTS[key]); } - set(key: K, value: StateData[K]): Thenable { - return this.extensionContext.globalState.update(key, value); + async set(key: K, value: StateData[K]): Promise { + return await this.extensionContext.globalState.update(key, value); } } diff --git a/packages/cursorless-vscode-core/ide/vscode/VscodeOpenLink.ts b/packages/cursorless-vscode-core/ide/vscode/VscodeOpenLink.ts index 1b65ba197e..aa36a12c18 100644 --- a/packages/cursorless-vscode-core/ide/vscode/VscodeOpenLink.ts +++ b/packages/cursorless-vscode-core/ide/vscode/VscodeOpenLink.ts @@ -23,11 +23,13 @@ export default async function vscodeOpenLink( return true; } -function getLinksForEditor(editor: vscode.TextEditor) { - return vscode.commands.executeCommand( +async function getLinksForEditor( + editor: vscode.TextEditor, +): Promise { + return (await vscode.commands.executeCommand( "vscode.executeLinkProvider", editor.document.uri, - ) as Thenable; + ))!; } function openLink(link: vscode.DocumentLink) { diff --git a/packages/cursorless-vscode-e2e/suite/recorded.test.ts b/packages/cursorless-vscode-e2e/suite/recorded.test.ts index 72e55c5d8a..b4e93c6e71 100644 --- a/packages/cursorless-vscode-e2e/suite/recorded.test.ts +++ b/packages/cursorless-vscode-e2e/suite/recorded.test.ts @@ -176,10 +176,8 @@ async function runTest(file: string, spyIde: SpyIDE) { spyIde.activeTextEditor!, spyIde, marks, - undefined, - undefined, // FIXME: Stop overriding the clipboard once we have #559 - vscode.env.clipboard, + true, ); const rawSpyIdeValues = spyIde.getSpyValues(fixture.ide?.flashes != null); diff --git a/packages/cursorless-vscode/constructTestHelpers.ts b/packages/cursorless-vscode/constructTestHelpers.ts index 505528843b..9fe17775d8 100644 --- a/packages/cursorless-vscode/constructTestHelpers.ts +++ b/packages/cursorless-vscode/constructTestHelpers.ts @@ -1,7 +1,6 @@ import { CommandServerApi, ExcludableSnapshotField, - ExtraContext, ExtraSnapshotField, IDE, NormalizedIDE, @@ -43,10 +42,8 @@ export function constructTestHelpers( extraFields: ExtraSnapshotField[], editor: TextEditor, ide: IDE, - marks?: SerializedMarks, - extraContext?: ExtraContext, - metadata?: unknown, - clipboard?: vscode.Clipboard, + marks: SerializedMarks | undefined, + forceRealClipboard: boolean, ): Promise { return takeSnapshot( thatMark, @@ -56,9 +53,9 @@ export function constructTestHelpers( editor, ide, marks, - extraContext, - metadata, - clipboard, + undefined, + undefined, + forceRealClipboard ? vscodeIDE.clipboard : undefined, ); }, diff --git a/packages/vscode-common/getExtensionApi.ts b/packages/vscode-common/getExtensionApi.ts index 72c1c06eb5..c455b87f6d 100644 --- a/packages/vscode-common/getExtensionApi.ts +++ b/packages/vscode-common/getExtensionApi.ts @@ -1,7 +1,6 @@ import type { CommandServerApi, ExcludableSnapshotField, - ExtraContext, ExtraSnapshotField, HatTokenMap, IDE, @@ -41,10 +40,8 @@ export interface TestHelpers { extraFields: ExtraSnapshotField[], editor: TextEditor, ide: IDE, - marks?: SerializedMarks, - extraContext?: ExtraContext, - metadata?: unknown, - clipboard?: vscode.Clipboard, + marks: SerializedMarks | undefined, + forceRealClipboard: boolean, ): Promise; }