Skip to content

Commit

Permalink
Clean up disposables in early-return path of ClangdContext.create() (#…
Browse files Browse the repository at this point in the history
…743)

Other minor cleanup:
  - do not await config.get(), it's not async
  - move initialization of clangdArguments into create()
  • Loading branch information
HighCommander4 authored Dec 4, 2024
1 parent fce0087 commit ea33181
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/clangd-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,18 @@ export class ClangdContext implements vscode.Disposable {
Promise<ClangdContext|null> {
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<string[]>('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<string[]>('arguments');
const clangd: vscodelc.Executable = {
command: clangdPath,
args: clangdArguments,
Expand Down

0 comments on commit ea33181

Please sign in to comment.