Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
filip131311 committed Feb 28, 2025
1 parent 8e18b0a commit d97f8ce
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions packages/vscode-extension/src/utilities/extensionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,27 @@ function searchForFilesDirectory(

const filesAndDirs = fs.readdirSync(currentDir.path.toString(), { withFileTypes: true });

let matched = false;

filesAndDirs.forEach((dirEntry) => {
if (dirEntry.isFile()) {
if (!matched && searchedFileNames.includes(dirEntry.name)) {
results.push(currentDir!.path);
matched = true;
}
return;
}
const isCandidate = filesAndDirs.some((dirEntry) => {
return dirEntry.isFile() && searchedFileNames.includes(dirEntry.name);
});

if (excludedDirectoryPatterns.some((pattern) => pattern.test(dirEntry.name))) {
return;
}
if (isCandidate) {
results.push(currentDir.path);
}

searchQueue.push({
path: currentDir!.path + "/" + dirEntry.name,
searchDepth: currentDir!.searchDepth + 1,
filesAndDirs
.filter((dirEntry) => {
return (
!dirEntry.isFile() &&
!excludedDirectoryPatterns.some((pattern) => pattern.test(dirEntry.name))
);
})
.forEach((dir) => {
searchQueue.push({
path: currentDir!.path + "/" + dir.name,
searchDepth: currentDir!.searchDepth + 1,
});
});
});
}

return results;
Expand Down

0 comments on commit d97f8ce

Please sign in to comment.