diff options
Diffstat (limited to 'editors/code/src/inlay_hints.ts')
-rw-r--r-- | editors/code/src/inlay_hints.ts | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index 6357e44f1..1c019a51b 100644 --- a/editors/code/src/inlay_hints.ts +++ b/editors/code/src/inlay_hints.ts | |||
@@ -5,19 +5,27 @@ import { Ctx, sendRequestWithRetry } from './ctx'; | |||
5 | 5 | ||
6 | export function activateInlayHints(ctx: Ctx) { | 6 | export function activateInlayHints(ctx: Ctx) { |
7 | const hintsUpdater = new HintsUpdater(ctx); | 7 | const hintsUpdater = new HintsUpdater(ctx); |
8 | vscode.window.onDidChangeVisibleTextEditors(async _ => { | 8 | vscode.window.onDidChangeVisibleTextEditors( |
9 | await hintsUpdater.refresh(); | 9 | async _ => hintsUpdater.refresh(), |
10 | }, ctx.subscriptions); | 10 | null, |
11 | 11 | ctx.subscriptions | |
12 | vscode.workspace.onDidChangeTextDocument(async e => { | 12 | ); |
13 | if (e.contentChanges.length === 0) return; | 13 | |
14 | if (e.document.languageId !== 'rust') return; | 14 | vscode.workspace.onDidChangeTextDocument( |
15 | await hintsUpdater.refresh(); | 15 | async event => { |
16 | }, ctx.subscriptions); | 16 | if (event.contentChanges.length !== 0) return; |
17 | 17 | if (event.document.languageId !== 'rust') return; | |
18 | vscode.workspace.onDidChangeConfiguration(_ => { | 18 | await hintsUpdater.refresh(); |
19 | hintsUpdater.setEnabled(ctx.config.displayInlayHints); | 19 | }, |
20 | }, ctx.subscriptions); | 20 | null, |
21 | ctx.subscriptions | ||
22 | ); | ||
23 | |||
24 | vscode.workspace.onDidChangeConfiguration( | ||
25 | async _ => hintsUpdater.setEnabled(ctx.config.displayInlayHints), | ||
26 | null, | ||
27 | ctx.subscriptions | ||
28 | ); | ||
21 | 29 | ||
22 | ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints)); | 30 | ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints)); |
23 | } | 31 | } |
@@ -127,13 +135,13 @@ class HintsUpdater { | |||
127 | } | 135 | } |
128 | 136 | ||
129 | private async queryHints(documentUri: string): Promise<InlayHint[] | null> { | 137 | private async queryHints(documentUri: string): Promise<InlayHint[] | null> { |
130 | let client = this.ctx.client; | 138 | const client = this.ctx.client; |
131 | if (!client) return null; | 139 | if (!client) return null; |
132 | const request: InlayHintsParams = { | 140 | const request: InlayHintsParams = { |
133 | textDocument: { uri: documentUri }, | 141 | textDocument: { uri: documentUri }, |
134 | }; | 142 | }; |
135 | let tokenSource = new vscode.CancellationTokenSource(); | 143 | const tokenSource = new vscode.CancellationTokenSource(); |
136 | let prev = this.pending.get(documentUri); | 144 | const prev = this.pending.get(documentUri); |
137 | if (prev) prev.cancel(); | 145 | if (prev) prev.cancel(); |
138 | this.pending.set(documentUri, tokenSource); | 146 | this.pending.set(documentUri, tokenSource); |
139 | try { | 147 | try { |