Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two bugs with trusted compiler paths #11998

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}

Expand Down
5 changes: 0 additions & 5 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading