aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/inlay_hints.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/inlay_hints.ts')
-rw-r--r--editors/code/src/inlay_hints.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
index b6eb70168..e74d6996f 100644
--- a/editors/code/src/inlay_hints.ts
+++ b/editors/code/src/inlay_hints.ts
@@ -1,7 +1,7 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3 3
4import { Ctx } from './ctx'; 4import { Ctx, sendRequestWithRetry } from './ctx';
5 5
6export function activateInlayHints(ctx: Ctx) { 6export function activateInlayHints(ctx: Ctx) {
7 const hintsUpdater = new HintsUpdater(ctx); 7 const hintsUpdater = new HintsUpdater(ctx);
@@ -19,9 +19,7 @@ export function activateInlayHints(ctx: Ctx) {
19 hintsUpdater.setEnabled(ctx.config.displayInlayHints); 19 hintsUpdater.setEnabled(ctx.config.displayInlayHints);
20 }, ctx.subscriptions); 20 }, ctx.subscriptions);
21 21
22 // XXX: don't await here; 22 ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints))
23 // Who knows what happens if an exception is thrown here...
24 hintsUpdater.refresh();
25} 23}
26 24
27interface InlayHintsParams { 25interface InlayHintsParams {
@@ -97,6 +95,8 @@ class HintsUpdater {
97 } 95 }
98 96
99 private async queryHints(documentUri: string): Promise<InlayHint[] | null> { 97 private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
98 let client = this.ctx.client;
99 if (!client) return null
100 const request: InlayHintsParams = { 100 const request: InlayHintsParams = {
101 textDocument: { uri: documentUri }, 101 textDocument: { uri: documentUri },
102 }; 102 };
@@ -105,7 +105,8 @@ class HintsUpdater {
105 if (prev) prev.cancel(); 105 if (prev) prev.cancel();
106 this.pending.set(documentUri, tokenSource); 106 this.pending.set(documentUri, tokenSource);
107 try { 107 try {
108 return await this.ctx.sendRequestWithRetry<InlayHint[] | null>( 108 return await sendRequestWithRetry<InlayHint[] | null>(
109 client,
109 'rust-analyzer/inlayHints', 110 'rust-analyzer/inlayHints',
110 request, 111 request,
111 tokenSource.token, 112 tokenSource.token,