From 48b120cf0b0e2ca1738657550fd8820c3994cc63 Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson Date: Mon, 18 Oct 2021 13:02:50 -0700 Subject: [PATCH] Fix issue with default configs --- Extension/src/LanguageServer/settings.ts | 26 +++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Extension/src/LanguageServer/settings.ts b/Extension/src/LanguageServer/settings.ts index edff3a4866..f0bfd04523 100644 --- a/Extension/src/LanguageServer/settings.ts +++ b/Extension/src/LanguageServer/settings.ts @@ -61,6 +61,18 @@ class Settings { } return result; } + + protected getWithUndefinedDefault(section: string): T | undefined { + const info: any = this.settings.inspect(section); + if (info.workspaceFolderValue !== undefined) { + return info.workspaceFolderValue; + } else if (info.workspaceValue !== undefined) { + return info.workspaceValue; + } else if (info.globalValue !== undefined) { + return info.globalValue; + } + return undefined; + } } export class CppSettings extends Settings { @@ -148,23 +160,23 @@ export class CppSettings extends Settings { public get addNodeAddonIncludePaths(): boolean | undefined { return super.Section.get("addNodeAddonIncludePaths"); } public get renameRequiresIdentifier(): boolean | undefined { return super.Section.get("renameRequiresIdentifier"); } public get filesExclude(): vscode.WorkspaceConfiguration | undefined { return super.Section.get("files.exclude"); } - public get defaultIncludePath(): string[] | undefined { return super.Section.get("default.includePath"); } - public get defaultDefines(): string[] | undefined { return super.Section.get("default.defines"); } - public get defaultMacFrameworkPath(): string[] | undefined { return super.Section.get("default.macFrameworkPath"); } + public get defaultIncludePath(): string[] | undefined { return super.getWithUndefinedDefault("default.includePath"); } + public get defaultDefines(): string[] | undefined { return super.getWithUndefinedDefault("default.defines"); } + public get defaultMacFrameworkPath(): string[] | undefined { return super.getWithUndefinedDefault("default.macFrameworkPath"); } public get defaultWindowsSdkVersion(): string | undefined { return super.Section.get("default.windowsSdkVersion"); } public get defaultCompileCommands(): string | undefined { return super.Section.get("default.compileCommands"); } - public get defaultForcedInclude(): string[] | undefined { return super.Section.get("default.forcedInclude"); } + public get defaultForcedInclude(): string[] | undefined { return super.getWithUndefinedDefault("default.forcedInclude"); } public get defaultIntelliSenseMode(): string | undefined { return super.Section.get("default.intelliSenseMode"); } public get defaultCompilerPath(): string | undefined { return super.Section.get("default.compilerPath") ?? undefined; } - public get defaultCompilerArgs(): string[] | undefined { return super.Section.get("default.compilerArgs"); } + public get defaultCompilerArgs(): string[] | undefined { return super.getWithUndefinedDefault("default.compilerArgs"); } public get defaultCStandard(): string | undefined { return super.Section.get("default.cStandard"); } public get defaultCppStandard(): string | undefined { return super.Section.get("default.cppStandard"); } public get defaultConfigurationProvider(): string | undefined { return super.Section.get("default.configurationProvider"); } public get defaultMergeConfigurations(): boolean | undefined { return super.Section.get("default.mergeConfigurations"); } - public get defaultBrowsePath(): string[] | undefined { return super.Section.get("default.browse.path") ?? undefined; } + public get defaultBrowsePath(): string[] | undefined { return super.getWithUndefinedDefault("default.browse.path") ?? undefined; } public get defaultDatabaseFilename(): string | undefined { return super.Section.get("default.browse.databaseFilename"); } public get defaultLimitSymbolsToIncludedHeaders(): boolean | undefined { return super.Section.get("default.browse.limitSymbolsToIncludedHeaders"); } - public get defaultSystemIncludePath(): string[] | undefined { return super.Section.get("default.systemIncludePath"); } + public get defaultSystemIncludePath(): string[] | undefined { return super.getWithUndefinedDefault("default.systemIncludePath"); } public get defaultEnableConfigurationSquiggles(): boolean | undefined { return super.Section.get("default.enableConfigurationSquiggles"); } public get defaultCustomConfigurationVariables(): { [key: string]: string } | undefined { return super.Section.get<{ [key: string]: string }>("default.customConfigurationVariables"); } public get useBacktickCommandSubstitution(): boolean | undefined { return super.Section.get("debugger.useBacktickCommandSubstitution"); }