diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index cfa0996ea..b62243a46 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) { + 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 + ) { + configuration.browse.path.push("${workspaceFolder}"); + } } } else { configuration.browse.path = ["${workspaceFolder}"];