Skip to content

Commit 98f13a6

Browse files
Merge pull request #10815 from microsoft/main
Don't put the compiler selection in the global settings if using the …
2 parents 0d85aea + 7b3ac0a commit 98f13a6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ export class DefaultClient implements Client {
989989
}
990990

991991
public async handleIntelliSenseConfigurationQuickPick(showSecondPrompt: boolean, sender?: any, compilersOnly?: boolean): Promise<void> {
992-
const settings: CppSettings = new CppSettings();
992+
const settings: CppSettings = new CppSettings(compilersOnly ? undefined : this.RootUri);
993993
const selectCompiler: string = localize("selectCompiler.string", "Select IntelliSense Configuration...");
994994
const paths: string[] = [];
995995
const configProviders: CustomConfigurationProvider1[] | undefined = compilersOnly ? undefined : this.configStateReceived.configProviders;

Extension/src/LanguageServer/settings.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,13 @@ export class CppSettings extends Settings {
382382
public set defaultCompilerPath(value: string | undefined) {
383383
const defaultCompilerPathStr: string = "default.compilerPath";
384384
const compilerPathInfo: any = this.Section.inspect(defaultCompilerPathStr);
385-
this.Section.update(defaultCompilerPathStr, value,
386-
compilerPathInfo.workspaceFolderValue !== undefined ? vscode.ConfigurationTarget.WorkspaceFolder :
387-
(compilerPathInfo.workspaceValue !== undefined ? vscode.ConfigurationTarget.Workspace :
388-
vscode.ConfigurationTarget.Global));
385+
let target: vscode.ConfigurationTarget = vscode.ConfigurationTarget.Global;
386+
if (this.resource !== undefined || compilerPathInfo.workspaceFolderValue !== undefined) {
387+
target = vscode.ConfigurationTarget.WorkspaceFolder;
388+
} else if (compilerPathInfo.workspaceValue !== undefined) {
389+
target = vscode.ConfigurationTarget.Workspace;
390+
}
391+
this.Section.update(defaultCompilerPathStr, value, target);
389392
}
390393
public get defaultCompilerArgs(): string[] | undefined { return super.getWithUndefinedDefault<string[]>("default.compilerArgs"); }
391394
public get defaultCStandard(): string | undefined { return super.Section.get<string>("default.cStandard"); }

0 commit comments

Comments
 (0)