diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c3b6d33a..6989505f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Bug Fixes: - Fix our setting of `isUserPreset` for presets, only set it to `true` if it's defined in a user presets file. [#4059](https://github.com/microsoft/vscode-cmake-tools/issues/4059) - Fix issue where duplicate presets are being listed in dropdown. [#4104](https://github.com/microsoft/vscode-cmake-tools/issues/4104) +- Fix auto select active project corner case. [#4146](https://github.com/microsoft/vscode-cmake-tools/issues/4146) Contributed by STMicroelectronics ## 1.19.52 diff --git a/src/util.ts b/src/util.ts index 0145a93b1..de7ce993e 100644 --- a/src/util.ts +++ b/src/util.ts @@ -947,7 +947,13 @@ export async function scheduleAsyncTask(task: () => Promise): Promise { export function isFileInsideFolder(uri: vscode.Uri, folderPath: string): boolean { const parent = platformNormalizePath(folderPath); const file = platformNormalizePath(uri.fsPath); - return file.startsWith(parent); + + // Ensure project path ends with a path separator to avoid partial matches + const parentWithEndingSeparator = parent.endsWith(path.posix.sep) + ? parent + : `${parent}${path.posix.sep}`; + + return file.startsWith(parentWithEndingSeparator); } /**