Skip to content

Commit

Permalink
Exclude **/node_modules/** from .java files search
Browse files Browse the repository at this point in the history
  • Loading branch information
gluxon committed Oct 20, 2023
1 parent f598b79 commit 9525c16
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,15 +918,19 @@ async function getTriggerFiles(): Promise<string[]> {
}
}

const javaFilesUnderRoot: Uri[] = await workspace.findFiles(new RelativePattern(rootFolder, "*.java"), undefined, 1);
// Excluding "**/node_modules/**" as a common cause of excessive CPU usage.
// https://github.com/microsoft/vscode/issues/75314#issuecomment-503195666
const exclusionBlob = "**/node_modules/**"

const javaFilesUnderRoot: Uri[] = await workspace.findFiles(new RelativePattern(rootFolder, "*.java"), exclusionBlob, 1);
for (const javaFile of javaFilesUnderRoot) {
if (isPrefix(rootPath, javaFile.fsPath)) {
openedJavaFiles.push(javaFile.toString());
return;
}
}

const javaFilesInCommonPlaces: Uri[] = await workspace.findFiles(new RelativePattern(rootFolder, "{src, test}/**/*.java"), undefined, 1);
const javaFilesInCommonPlaces: Uri[] = await workspace.findFiles(new RelativePattern(rootFolder, "{src, test}/**/*.java"), exclusionBlob, 1);
for (const javaFile of javaFilesInCommonPlaces) {
if (isPrefix(rootPath, javaFile.fsPath)) {
openedJavaFiles.push(javaFile.toString());
Expand Down

0 comments on commit 9525c16

Please sign in to comment.