Skip to content

Commit d3d2316

Browse files
committed
pre-review
1 parent 77ff126 commit d3d2316

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

Extension/c_cpp_properties.schema.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
"compilerPath": {
1919
"markdownDescription": "Full path of the compiler being used, e.g. `/usr/bin/gcc`, to enable more accurate IntelliSense.",
2020
"descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",
21-
"type": [
22-
"string",
23-
"null"
24-
]
21+
"type": "string"
2522
},
2623
"compilerArgs": {
2724
"markdownDescription": "Compiler arguments to modify the includes or defines used, e.g. `-nostdinc++`, `-m32`, etc. Arguments that take additional space-delimited arguments should be entered as separate arguments in the array, e.g. for `--sysroot <arg>` use `\"--sysroot\", \"<arg>\"`.",
@@ -312,4 +309,4 @@
312309
"version"
313310
],
314311
"additionalProperties": false
315-
}
312+
}

Extension/src/LanguageServer/configurations.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,8 @@ export class CppProperties {
15991599
* Get the compilerPath and args from a compilerPath string that has already passed through
16001600
* `this.resolvePath`. If there are errors processing the path, those will also be returned.
16011601
*
1602-
* @resolvedCompilerPath a compilerPath string that has already been resolved.
1602+
* @param resolvedCompilerPath a compilerPath string that has already been resolved.
1603+
* @param rootUri the workspace folder URI, if any.
16031604
*/
16041605
public static validateCompilerPath(resolvedCompilerPath: string, rootUri?: vscode.Uri): util.CompilerPathAndArgs {
16051606
if (!resolvedCompilerPath) {
@@ -1629,16 +1630,16 @@ export class CppProperties {
16291630
resolvedCompilerPath = pathLocation;
16301631
compilerPathAndArgs.compilerPath = pathLocation;
16311632
} else if (rootUri) {
1632-
// Check again for a relative path.
1633-
const relativePath: string = rootUri.fsPath + path.sep + resolvedCompilerPath;
1634-
if (!fs.existsSync(relativePath)) {
1635-
if (existsWithExeAdded(relativePath)) {
1636-
resolvedCompilerPath = relativePath + ".exe";
1633+
// Test if it was a relative path.
1634+
const absolutePath: string = rootUri.fsPath + path.sep + resolvedCompilerPath;
1635+
if (!fs.existsSync(absolutePath)) {
1636+
if (existsWithExeAdded(absolutePath)) {
1637+
resolvedCompilerPath = absolutePath + ".exe";
16371638
} else {
16381639
pathExists = false;
16391640
}
16401641
} else {
1641-
resolvedCompilerPath = relativePath;
1642+
resolvedCompilerPath = absolutePath;
16421643
}
16431644
}
16441645
}

Extension/src/common.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,13 @@ export interface CompilerPathAndArgs {
11021102
}
11031103

11041104
/**
1105-
* Parse the compiler path input into a compiler path and compiler args. If there are no args, the compilerPath will have been verified to exist.
1105+
* Parse the compiler path input into a compiler path and compiler args. If there are no args in the input string, this function will have
1106+
* verified that the compiler exists. (e.g. `compilerArgsFromCommandLineInPath` will be empty)
1107+
*
1108+
* @param useLegacyBehavior - If true, use the legacy behavior of separating the compilerPath from the args.
1109+
* @param inputCompilerPath - The compiler path input from the user.
1110+
* @param compilerArgs - The compiler args input from the user.
1111+
* @param cwd - The directory used to resolve relative paths.
11061112
*/
11071113
export function extractCompilerPathAndArgs(useLegacyBehavior: boolean, inputCompilerPath?: string, compilerArgs?: string[], cwd?: string): CompilerPathAndArgs {
11081114
let compilerPath: string | undefined = inputCompilerPath;
@@ -1137,7 +1143,7 @@ export function extractCompilerPathAndArgs(useLegacyBehavior: boolean, inputComp
11371143
}
11381144
} else {
11391145
if (compilerPath.includes(' ')) {
1140-
// There is no leading quote, so we'll treat it as a command line.
1146+
// There is no leading quote, but there is a space so we'll treat it as a command line.
11411147
const potentialArgs: string[] = useLegacyBehavior ? legacyExtractArgs(compilerPath) : extractArgs(compilerPath);
11421148
compilerPath = trimLegacyQuotes(potentialArgs.shift());
11431149
compilerArgsFromCommandLineInPath = potentialArgs;

0 commit comments

Comments
 (0)