From ea3318166850feb7b5985e45fbfd99045a648d54 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Wed, 4 Dec 2024 03:27:44 -0500 Subject: [PATCH] Clean up disposables in early-return path of ClangdContext.create() (#743) Other minor cleanup: - do not await config.get(), it's not async - move initialization of clangdArguments into create() --- src/clangd-context.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/clangd-context.ts b/src/clangd-context.ts index 0fe04ff..3b3d5d5 100644 --- a/src/clangd-context.ts +++ b/src/clangd-context.ts @@ -65,19 +65,18 @@ export class ClangdContext implements vscode.Disposable { Promise { const subscriptions: vscode.Disposable[] = []; const clangdPath = await install.activate(subscriptions, globalStoragePath); - if (!clangdPath) + if (!clangdPath) { + subscriptions.forEach((d) => { d.dispose(); }); return null; + } - const clangdArguments = await config.get('arguments'); - - return new ClangdContext(subscriptions, clangdPath, clangdArguments, - outputChannel); + return new ClangdContext(subscriptions, clangdPath, outputChannel); } private constructor(subscriptions: vscode.Disposable[], clangdPath: string, - clangdArguments: string[], outputChannel: vscode.OutputChannel) { this.subscriptions = subscriptions; + const clangdArguments = config.get('arguments'); const clangd: vscodelc.Executable = { command: clangdPath, args: clangdArguments,