Skip to content

Commit 5967358

Browse files
authored
Fix #4304 #2903: Unrelated symlink files showing as variants (#4387)
* Fixes #4304 #2903 chokidar library has a bug where it shows unwatched symlinks, to prevent crashes dont further process files that is not in candidates. * Fix variant file path finding logic * Fix tests + add changelog * Load valid variant file * Fix formatting
1 parent cdfb2ce commit 5967358

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Bug Fixes:
1919
- Fixes for small bug string bugs. [#4319](https://github.com/microsoft/vscode-cmake-tools/issues/4319), [#4317](https://github.com/microsoft/vscode-cmake-tools/issues/4317), [#4312](https://github.com/microsoft/vscode-cmake-tools/issues/4312)
2020
- Fixes localization for "workspace is" string. [#4374](https://github.com/microsoft/vscode-cmake-tools/issues/4374)
2121
- Make tooltips for selecting Launch/Debug Target. [#4373](https://github.com/microsoft/vscode-cmake-tools/issues/4373)
22+
- Fix bug where unrelated symlinks are read as variant files [#4304](https://github.com/microsoft/vscode-cmake-tools/issues/4304) [@vitorramos](https://github.com/vitorramos).
2223

2324
## 1.20.53
2425

src/kits/variant.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,22 @@ export class VariantManager implements vscode.Disposable {
252252
path.join(workspaceFolder, '.vscode/cmake-variants.yaml')
253253
];
254254

255+
let foundCandidate = false;
255256
if (!filepath || !await fs.exists(filepath) || !candidates.includes(filepath)) {
256257
for (const testpath of candidates) {
257258
if (await fs.exists(testpath)) {
258259
filepath = testpath;
260+
foundCandidate = true;
259261
break;
260262
}
261263
}
264+
} else {
265+
foundCandidate = true;
262266
}
263267

264268
let new_variants = this.loadVariantsFromSettings();
265269
// Check once more that we have a file to read
266-
if (filepath && await fs.exists(filepath)) {
270+
if (foundCandidate && filepath && await fs.exists(filepath)) {
267271
this.customVariantsFileExists = true;
268272
const content = (await fs.readFile(filepath)).toString();
269273
try {

0 commit comments

Comments
 (0)