Skip to content

Commit ea23201

Browse files
committed
fix: exclude node_modules at findFiles level to avoid enumerating thousands of dependency files
1 parent 7bd6e16 commit ea23201

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/commands/batch-organizer.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ export class BatchOrganizer {
157157

158158
this.logger.appendLine(`[BatchOrganizer] Searching workspace: ${include}`);
159159

160-
// Find all files (undefined = VS Code respects files.exclude; null would bypass it)
161-
const allFiles = await workspace.findFiles(include, undefined);
160+
// Pass '**/node_modules/**' to findFiles to avoid enumerating thousands of dependency files.
161+
// 'undefined' would only respect files.exclude (which doesn't include node_modules by default).
162+
// Our manual filter below handles the remaining exclude patterns (dist, build, out, user patterns).
163+
const allFiles = await workspace.findFiles(include, '**/node_modules/**');
162164

163165
// Manually filter files using exclude patterns
164166
// IMPORTANT: Get excludePatterns per file based on its workspace folder
@@ -197,7 +199,8 @@ export class BatchOrganizer {
197199
// Use RelativePattern to scope findFiles to the specific workspace folder
198200
// (plain string patterns search across ALL workspace roots in multi-root workspaces)
199201
const include = new RelativePattern(workspaceFolder, includeGlob);
200-
const allFiles = await workspace.findFiles(include, undefined);
202+
// Pass '**/node_modules/**' to findFiles to avoid enumerating thousands of dependency files.
203+
const allFiles = await workspace.findFiles(include, '**/node_modules/**');
201204

202205
// Manually filter files using exclude patterns
203206
const files = allFiles.filter(fileUri => !this.isFileExcluded(fileUri, excludePatterns));

0 commit comments

Comments
 (0)