From 665e82e111403c053634cc6b1d16d3541de59f6a Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson Date: Thu, 20 Feb 2025 12:40:06 -0800 Subject: [PATCH 1/2] Fix an issue with C: treated as a relative path --- Extension/src/LanguageServer/configurations.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index e9c7a86b2..6979e9a4a 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -1574,9 +1574,11 @@ export class CppProperties { quoted = true; result = result.slice(1, -1); } + // On Windows, isAbsolute does not handle root paths without a slash, such as "C:" + const isWindowsRootPath: boolean = (process.platform === 'win32' && /^[a-zA-Z]:$/.test(result)); // Make sure all paths result to an absolute path. // Do not add the root path to an unresolved env variable. - if (!result.includes("env:") && !path.isAbsolute(result) && this.rootUri) { + if (!isWindowsRootPath && !result.includes("env:") && !path.isAbsolute(result) && this.rootUri) { result = path.join(this.rootUri.fsPath, result); } if (quoted) { From 14ddecf2e70bcc1c187b64958701dc64265ae343 Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson Date: Thu, 20 Feb 2025 13:39:06 -0800 Subject: [PATCH 2/2] Fix lint issue --- Extension/src/LanguageServer/configurations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index 6979e9a4a..cfa0996ea 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -1575,7 +1575,7 @@ export class CppProperties { result = result.slice(1, -1); } // On Windows, isAbsolute does not handle root paths without a slash, such as "C:" - const isWindowsRootPath: boolean = (process.platform === 'win32' && /^[a-zA-Z]:$/.test(result)); + const isWindowsRootPath: boolean = process.platform === 'win32' && /^[a-zA-Z]:$/.test(result); // Make sure all paths result to an absolute path. // Do not add the root path to an unresolved env variable. if (!isWindowsRootPath && !result.includes("env:") && !path.isAbsolute(result) && this.rootUri) {