From 087af54069d34eef5197e04d64ac322d9ee98085 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Dec 2019 18:14:00 +0100 Subject: Refactor server lifecycle --- editors/code/src/inlay_hints.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'editors/code/src/inlay_hints.ts') 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 @@ import * as vscode from 'vscode'; import * as lc from 'vscode-languageclient'; -import { Ctx } from './ctx'; +import { Ctx, sendRequestWithRetry } from './ctx'; export function activateInlayHints(ctx: Ctx) { const hintsUpdater = new HintsUpdater(ctx); @@ -19,9 +19,7 @@ export function activateInlayHints(ctx: Ctx) { hintsUpdater.setEnabled(ctx.config.displayInlayHints); }, ctx.subscriptions); - // XXX: don't await here; - // Who knows what happens if an exception is thrown here... - hintsUpdater.refresh(); + ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints)) } interface InlayHintsParams { @@ -97,6 +95,8 @@ class HintsUpdater { } private async queryHints(documentUri: string): Promise { + let client = this.ctx.client; + if (!client) return null const request: InlayHintsParams = { textDocument: { uri: documentUri }, }; @@ -105,7 +105,8 @@ class HintsUpdater { if (prev) prev.cancel(); this.pending.set(documentUri, tokenSource); try { - return await this.ctx.sendRequestWithRetry( + return await sendRequestWithRetry( + client, 'rust-analyzer/inlayHints', request, tokenSource.token, -- cgit v1.2.3