Skip to content

Commit

Permalink
Move requesting of config to the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
JVApen committed Nov 19, 2024
1 parent bb1d76e commit 9942c87
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/clangd-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,26 @@ export class ClangdContext implements vscode.Disposable {
if (!clangdPath)
return null;

const useScriptAsExecutable =
await config.get<boolean>('useScriptAsExecutable');
const clangdArguments = await config.get<string[]>('arguments');

return new ClangdContext(clangdPath, clangdArguments, outputChannel,
useScriptAsExecutable);
return new ClangdContext(clangdPath, outputChannel);
}

private constructor(clangdPath: string, clangdArguments: string[],
outputChannel: vscode.OutputChannel,
useScriptAsExecutable: boolean) {
private constructor(clangdPath: string, outputChannel: vscode.OutputChannel) {
const useScriptAsExecutable = config.get<boolean>('useScriptAsExecutable');
let clangdArguments = config.get<string[]>('arguments');
if (useScriptAsExecutable) {
let quote = (str: string) => { return `"${str}"`; };
clangdPath = quote(clangdPath)
for (var i = 0; i < clangdArguments.length; i++)
clangdArguments[i] = quote(clangdArguments[i]);
for (var i = 0; i < clangdArguments.length; i++) {
clangdArguments[i] = quote(clangdArguments[i]);
}
}
const clangd: vscodelc.Executable = {
command: clangdPath,
args: clangdArguments,
options: {cwd: vscode.workspace.rootPath || process.cwd()}
options: {
cwd: vscode.workspace.rootPath || process.cwd(),
shell: useScriptAsExecutable
}
};
const traceFile = config.get<string>('trace');
if (!!traceFile) {
Expand Down

0 comments on commit 9942c87

Please sign in to comment.