Skip to content
Merged
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
10 changes: 5 additions & 5 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,13 @@ export class CppProperties {
if (configuration.compilerPath === undefined ||
configuration.compilerPath === "" ||
configuration.compilerPath === "${default}" ||
configuration.intelliSenseMode === undefined ||
configuration.intelliSenseMode === "" ||
configuration.intelliSenseMode === undefined ||
configuration.intelliSenseMode === "" ||
configuration.intelliSenseMode === "${default}") {
return true;
}
let compilerPathAndArgs: util.CompilerPathAndArgs = util.extractCompilerPathAndArgs(configuration.compilerPath);
return compilerPathAndArgs.compilerPath.endsWith("cl.exe") === (configuration.intelliSenseMode === "msvc-x64");
return (compilerPathAndArgs.compilerName === "cl.exe") === (configuration.intelliSenseMode === "msvc-x64");
}

public addToIncludePathCommand(path: string): void {
Expand Down Expand Up @@ -920,7 +920,7 @@ export class CppProperties {
let compilerPathAndArgs: util.CompilerPathAndArgs = util.extractCompilerPathAndArgs(resolvedCompilerPath);
if (resolvedCompilerPath &&
// Don't error cl.exe paths because it could be for an older preview build.
!(isWindows && compilerPathAndArgs.compilerPath.endsWith("cl.exe"))) {
!(isWindows && compilerPathAndArgs.compilerName === "cl.exe")) {
resolvedCompilerPath = resolvedCompilerPath.trim();

// Error when the compiler's path has spaces without quotes but args are used.
Expand Down Expand Up @@ -1139,7 +1139,7 @@ export class CppProperties {
if (isCompilerPath) {
resolvedPath = resolvedPath.trim();
let compilerPathAndArgs: util.CompilerPathAndArgs = util.extractCompilerPathAndArgs(resolvedPath);
if (isWindows && compilerPathAndArgs.compilerPath.endsWith("cl.exe")) {
if (isWindows && compilerPathAndArgs.compilerName === "cl.exe") {
continue; // Don't squiggle invalid cl.exe paths because it could be for an older preview build.
}
// Squiggle when the compiler's path has spaces without quotes but args are used.
Expand Down
9 changes: 8 additions & 1 deletion Extension/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,11 +771,13 @@ export function downloadFileToStr(urlStr: string, headers?: OutgoingHttpHeaders)

export interface CompilerPathAndArgs {
compilerPath: string;
compilerName: string;
additionalArgs: string[];
}

export function extractCompilerPathAndArgs(inputCompilerPath: string): CompilerPathAndArgs {
let compilerPath: string = inputCompilerPath;
let compilerName: string = "";
let additionalArgs: string[];
let isWindows: boolean = os.platform() === 'win32';
if (compilerPath) {
Expand All @@ -785,6 +787,7 @@ export function extractCompilerPathAndArgs(inputCompilerPath: string): CompilerP
additionalArgs = compilerPath.substr(endQuote + 1).split(" ");
additionalArgs = additionalArgs.filter((arg: string) => { return arg.trim().length !== 0; }); // Remove empty args.
compilerPath = compilerPath.substr(1, endQuote - 1);
compilerName = compilerPath.replace(/^.*(\\|\/|\:)/, '');
Comment thread
michelleangela marked this conversation as resolved.
}
} else {
// Go from right to left checking if a valid path is to the left of a space.
Expand All @@ -807,9 +810,13 @@ export function extractCompilerPathAndArgs(inputCompilerPath: string): CompilerP
compilerPath = potentialCompilerPath;
}
}
// Get compiler name if there are no args but path is valid or a valid path was found with args.
if (checkFileExistsSync(compilerPath)) {
compilerName = compilerPath.replace(/^.*(\\|\/|\:)/, '');
}
}
}
return { compilerPath, additionalArgs };
return { compilerPath, compilerName, additionalArgs };
}

export function escapeForSquiggles(s: string): string {
Expand Down