Skip to content

Commit ea33181

Browse files
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()
1 parent fce0087 commit ea33181

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/clangd-context.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,18 @@ export class ClangdContext implements vscode.Disposable {
6565
Promise<ClangdContext|null> {
6666
const subscriptions: vscode.Disposable[] = [];
6767
const clangdPath = await install.activate(subscriptions, globalStoragePath);
68-
if (!clangdPath)
68+
if (!clangdPath) {
69+
subscriptions.forEach((d) => { d.dispose(); });
6970
return null;
71+
}
7072

71-
const clangdArguments = await config.get<string[]>('arguments');
72-
73-
return new ClangdContext(subscriptions, clangdPath, clangdArguments,
74-
outputChannel);
73+
return new ClangdContext(subscriptions, clangdPath, outputChannel);
7574
}
7675

7776
private constructor(subscriptions: vscode.Disposable[], clangdPath: string,
78-
clangdArguments: string[],
7977
outputChannel: vscode.OutputChannel) {
8078
this.subscriptions = subscriptions;
79+
const clangdArguments = config.get<string[]>('arguments');
8180
const clangd: vscodelc.Executable = {
8281
command: clangdPath,
8382
args: clangdArguments,

0 commit comments

Comments
 (0)