From b120b804e1949423ace56e799d23199d6b972d2f Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Fri, 28 Feb 2025 13:05:18 -0800 Subject: [PATCH 1/2] Fix ${workspaceFolder} being added if ${workspaceFolder}/* is used. --- Extension/src/LanguageServer/configurations.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index cfa0996ea..f9e679de8 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -998,10 +998,15 @@ export class CppProperties { } else if (configuration.includePath) { // If the user doesn't set browse.path, copy the includePath over. Make sure ${workspaceFolder} is in there though... configuration.browse.path = configuration.includePath.slice(0); - if (configuration.includePath.findIndex((value: string) => - !!value.match(/^\$\{(workspaceRoot|workspaceFolder)\}(\\\*{0,2}|\/\*{0,2})?$/g)) === -1 - ) { - configuration.browse.path.push("${workspaceFolder}"); + if (this.rootUri) { + let normalizedRootUriFsPath: string = escapeStringRegExp(this.rootUri.fsPath.replace(/\\/g, "/")); + let regexPattern = `^${normalizedRootUriFsPath}(\\*{0,2}|\/\\*{0,2})?$`; + let regex = new RegExp(regexPattern, "g"); + if (configuration.includePath.findIndex((value: string) => + !!value.match(regex)) === -1 + ) { + configuration.browse.path.push("${workspaceFolder}"); + } } } else { configuration.browse.path = ["${workspaceFolder}"]; From 495932c7fa3a9e5c1d2e8cd20a7b37cdafd41300 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Fri, 28 Feb 2025 13:07:51 -0800 Subject: [PATCH 2/2] Fix linter. --- Extension/src/LanguageServer/configurations.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index f9e679de8..b62243a46 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -999,9 +999,9 @@ export class CppProperties { // If the user doesn't set browse.path, copy the includePath over. Make sure ${workspaceFolder} is in there though... configuration.browse.path = configuration.includePath.slice(0); if (this.rootUri) { - let normalizedRootUriFsPath: string = escapeStringRegExp(this.rootUri.fsPath.replace(/\\/g, "/")); - let regexPattern = `^${normalizedRootUriFsPath}(\\*{0,2}|\/\\*{0,2})?$`; - let regex = new RegExp(regexPattern, "g"); + const normalizedRootUriFsPath: string = escapeStringRegExp(this.rootUri.fsPath.replace(/\\/g, "/")); + const regexPattern = `^${normalizedRootUriFsPath}(\\*{0,2}|\/\\*{0,2})?$`; + const regex = new RegExp(regexPattern, "g"); if (configuration.includePath.findIndex((value: string) => !!value.match(regex)) === -1 ) {