Skip to content

Commit 5746586

Browse files
authored
Fix cl.exe not appearing in the compiler list. (#6884)
1 parent b1deef8 commit 5746586

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,17 @@ export class CppBuildTaskProvider implements TaskProvider {
114114
}
115115
}
116116

117+
const isCompilerValid: boolean = userCompilerPath ? await util.checkFileExists(userCompilerPath) : false;
118+
117119
// Get known compiler paths. Do not include the known compiler path that is the same as user compiler path.
118120
// Filter them based on the file type to get a reduced list appropriate for the active file.
119121
const knownCompilerPathsSet: Set<string> = new Set();
120122
let knownCompilers: configs.KnownCompiler[] | undefined = await activeClient.getKnownCompilers();
121123
if (knownCompilers) {
122124
knownCompilers = knownCompilers.filter(info =>
123125
((fileIsCpp && !info.isC) || (fileIsC && info.isC)) &&
124-
userCompilerPathAndArgs &&
125-
(path.basename(info.path) !== userCompilerPathAndArgs.compilerName) &&
126+
(!isCompilerValid || (userCompilerPathAndArgs &&
127+
(path.basename(info.path) !== userCompilerPathAndArgs.compilerName))) &&
126128
(!isWindows || !info.path.startsWith("/"))); // TODO: Add WSL compiler support.
127129
knownCompilers.map<void>(info => {
128130
knownCompilerPathsSet.add(info.path);
@@ -143,11 +145,8 @@ export class CppBuildTaskProvider implements TaskProvider {
143145
result = knownCompilerPaths.map<Task>(compilerPath => this.getTask(compilerPath, appendSourceToName, undefined));
144146
}
145147
// Task for valid user compiler path setting
146-
if (userCompilerPath) {
147-
const isCompilerValid: boolean = await util.checkFileExists(userCompilerPath);
148-
if (isCompilerValid) {
149-
result.push(this.getTask(userCompilerPath, appendSourceToName, userCompilerPathAndArgs?.additionalArgs));
150-
}
148+
if (isCompilerValid && userCompilerPath) {
149+
result.push(this.getTask(userCompilerPath, appendSourceToName, userCompilerPathAndArgs?.additionalArgs));
151150
}
152151
return result;
153152
}

0 commit comments

Comments
 (0)