Skip to content

Commit 836787d

Browse files
committed
Replace Thenables with Promises
1 parent c15b818 commit 836787d

File tree

7 files changed

+21
-19
lines changed

7 files changed

+21
-19
lines changed

packages/common/ide/fake/FakeGlobalState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class FakeGlobalState implements State {
88
return this.data[key];
99
}
1010

11-
set<K extends StateKey>(key: K, value: StateData[K]): Thenable<void> {
11+
set<K extends StateKey>(key: K, value: StateData[K]): Promise<void> {
1212
this.data[key] = value;
1313
return Promise.resolve();
1414
}

packages/common/ide/types/Clipboard.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
export interface Clipboard {
66
/**
77
* Read the current clipboard contents as text.
8-
* @returns A thenable that resolves to a string.
8+
* @returns A promise that resolves to a string.
99
*/
10-
readText(): Thenable<string>;
10+
readText(): Promise<string>;
1111

1212
/**
1313
* Writes text into the clipboard.
14-
* @returns A thenable that resolves when writing happened.
14+
* @returns A promise that resolves when writing happened.
1515
*/
16-
writeText(value: string): Thenable<void>;
16+
writeText(value: string): Promise<void>;
1717
}

packages/common/ide/types/State.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ export interface State {
2626
* @param key A string.
2727
* @param value A value. MUST not contain cyclic references.
2828
*/
29-
set<K extends StateKey>(key: K, value: StateData[K]): Thenable<void>;
29+
set<K extends StateKey>(key: K, value: StateData[K]): Promise<void>;
3030
}

packages/cursorless-engine/core/updateSelections/updateSelections.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function selectionInfosToSelections(
146146
*/
147147
export async function callFunctionAndUpdateSelections(
148148
rangeUpdater: RangeUpdater,
149-
func: () => Thenable<void>,
149+
func: () => Promise<void>,
150150
document: TextDocument,
151151
selectionMatrix: (readonly Selection[])[],
152152
): Promise<Selection[][]> {
@@ -165,7 +165,7 @@ export async function callFunctionAndUpdateSelections(
165165

166166
export async function callFunctionAndUpdateRanges(
167167
rangeUpdater: RangeUpdater,
168-
func: () => Thenable<void>,
168+
func: () => Promise<void>,
169169
document: TextDocument,
170170
rangeMatrix: (readonly Range[])[],
171171
): Promise<Range[][]> {
@@ -190,7 +190,7 @@ export async function callFunctionAndUpdateRanges(
190190
*/
191191
export async function callFunctionAndUpdateSelectionInfos(
192192
rangeUpdater: RangeUpdater,
193-
func: () => Thenable<void>,
193+
func: () => Promise<void>,
194194
document: TextDocument,
195195
selectionInfoMatrix: FullSelectionInfo[][],
196196
) {
@@ -217,7 +217,7 @@ export async function callFunctionAndUpdateSelectionInfos(
217217
*/
218218
export function callFunctionAndUpdateSelectionsWithBehavior(
219219
rangeUpdater: RangeUpdater,
220-
func: () => Thenable<void>,
220+
func: () => Promise<void>,
221221
document: TextDocument,
222222
originalSelections: SelectionsWithBehavior[],
223223
) {

packages/cursorless-vscode-core/ide/vscode/VscodeClipboard.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import * as vscode from "vscode";
22
import { Clipboard } from "@cursorless/common";
33

44
export default class VscodeClipboard implements Clipboard {
5-
readText(): Thenable<string> {
6-
return vscode.env.clipboard.readText();
5+
async readText(): Promise<string> {
6+
return await vscode.env.clipboard.readText();
77
}
88

9-
writeText(value: string): Thenable<void> {
10-
return vscode.env.clipboard.writeText(value);
9+
async writeText(value: string): Promise<void> {
10+
return await vscode.env.clipboard.writeText(value);
1111
}
1212
}

packages/cursorless-vscode-core/ide/vscode/VscodeGlobalState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class VscodeGlobalState implements State {
1212
return this.extensionContext.globalState.get(key, STATE_DEFAULTS[key]);
1313
}
1414

15-
set<K extends StateKey>(key: K, value: StateData[K]): Thenable<void> {
16-
return this.extensionContext.globalState.update(key, value);
15+
async set<K extends StateKey>(key: K, value: StateData[K]): Promise<void> {
16+
return await this.extensionContext.globalState.update(key, value);
1717
}
1818
}

packages/cursorless-vscode-core/ide/vscode/VscodeOpenLink.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export default async function vscodeOpenLink(
2323
return true;
2424
}
2525

26-
function getLinksForEditor(editor: vscode.TextEditor) {
27-
return vscode.commands.executeCommand(
26+
async function getLinksForEditor(
27+
editor: vscode.TextEditor,
28+
): Promise<vscode.DocumentLink[]> {
29+
return (await vscode.commands.executeCommand(
2830
"vscode.executeLinkProvider",
2931
editor.document.uri,
30-
) as Thenable<vscode.DocumentLink[]>;
32+
))!;
3133
}
3234

3335
function openLink(link: vscode.DocumentLink) {

0 commit comments

Comments
 (0)