From 21923714fa4839d58e8d01d9ca177788be6b837e Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson Date: Wed, 21 Feb 2024 17:32:08 -0800 Subject: [PATCH] Fix two bugs with trusted compiler paths --- Extension/src/LanguageServer/client.ts | 15 +++++++++------ Extension/src/LanguageServer/configurations.ts | 5 ----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index f11da524ac..64e441e060 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -2688,7 +2688,7 @@ export class DefaultClient implements Client { const configurationNotSet: boolean = configProviderNotSetAndNoCache && compileCommandsNotSet && compilerPathNotSet; showConfigStatus = showConfigStatus || (configurationNotSet && - !!compilerDefaults && !compilerDefaults.trustedCompilerFound && trustedCompilerPaths && (trustedCompilerPaths.length !== 1 || trustedCompilerPaths[0] !== "")); + !!compilerDefaults && !compilerDefaults.trustedCompilerFound && (trustedCompilerPaths.length !== 1 || trustedCompilerPaths[0] !== "")); const configProviderType: ConfigurationType = this.configuration.ConfigProviderAutoSelected ? ConfigurationType.AutoConfigProvider : ConfigurationType.ConfigProvider; const compilerType: ConfigurationType = this.configuration.CurrentConfiguration?.compilerPathIsExplicit ? ConfigurationType.CompilerPath : ConfigurationType.AutoCompilerPath; @@ -2905,6 +2905,11 @@ export class DefaultClient implements Client { params.configurations.push(modifiedConfig); }); + const trusted_compiler_path: string | undefined = params.configurations[params.currentConfiguration].compilerPath; + if (trusted_compiler_path) { + void this.addTrustedCompiler(trusted_compiler_path).catch(logAndReturn.undefined); + } + await this.languageClient.sendRequest(ChangeCppPropertiesRequest, params); if (!!this.lastCustomBrowseConfigurationProviderId && !!this.lastCustomBrowseConfiguration && !!this.lastCustomBrowseConfigurationProviderVersion) { if (!this.doneInitialCustomBrowseConfigurationCheck) { @@ -3870,13 +3875,11 @@ export class DefaultClient implements Client { if (path === null || path === undefined) { return; } - if (trustedCompilerPaths.includes(path)) { - DebugConfigurationProvider.ClearDetectedBuildTasks(); - return; + if (!trustedCompilerPaths.includes(path)) { + trustedCompilerPaths.push(path); } - trustedCompilerPaths.push(path); - compilerDefaults = await this.requestCompiler(path); DebugConfigurationProvider.ClearDetectedBuildTasks(); + compilerDefaults = await this.requestCompiler(path); } } diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index c1d011c745..12908892dd 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -976,11 +976,6 @@ export class CppProperties { configuration.macFrameworkPath = this.defaultFrameworks; } } - } else { - // add compiler to list of trusted compilers - if (i === this.CurrentConfigurationIndex) { - void this.client.addTrustedCompiler(configuration.compilerPath).catch(logAndReturn.undefined); - } } } else { // However, if compileCommands are used and compilerPath is explicitly set, it's still necessary to resolve variables in it.