From 8153b60e1d8abdcefbf6c7c9657f1ce65a216d7a Mon Sep 17 00:00:00 2001 From: Veetaha Date: Wed, 5 Feb 2020 22:39:47 +0200 Subject: vscode: eliminate floating promises and insane amount of resource handle leaks --- editors/code/src/inlay_hints.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 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 ae7510183..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'; export function activateInlayHints(ctx: Ctx) { const hintsUpdater = new HintsUpdater(ctx); - vscode.window.onDidChangeVisibleTextEditors(async _ => { - await hintsUpdater.refresh(); - }, ctx.subscriptions); - - vscode.workspace.onDidChangeTextDocument(async e => { - if (e.contentChanges.length === 0) return; - if (e.document.languageId !== 'rust') return; - await hintsUpdater.refresh(); - }, ctx.subscriptions); - - vscode.workspace.onDidChangeConfiguration(_ => { - hintsUpdater.setEnabled(ctx.config.displayInlayHints); - }, ctx.subscriptions); + vscode.window.onDidChangeVisibleTextEditors( + async _ => hintsUpdater.refresh(), + null, + ctx.subscriptions + ); + + vscode.workspace.onDidChangeTextDocument( + async event => { + if (event.contentChanges.length !== 0) return; + if (event.document.languageId !== 'rust') return; + await hintsUpdater.refresh(); + }, + null, + ctx.subscriptions + ); + + vscode.workspace.onDidChangeConfiguration( + async _ => hintsUpdater.setEnabled(ctx.config.displayInlayHints), + null, + ctx.subscriptions + ); ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints)); } -- cgit v1.2.3