Skip to content

Commit ac84c79

Browse files
committed
fix: pre-filter all default exclude patterns in batch organizer findFiles
Previously only node_modules was pre-filtered at the findFiles level. Now all default excludes (node_modules, dist, build, out, .git, coverage) are pre-filtered via brace expansion glob to avoid enumerating thousands of files in build artifacts and dependencies.
1 parent c86aa78 commit ac84c79

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/commands/batch-organizer.ts

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

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

160-
// Pass '**/node_modules/**' to findFiles to avoid enumerating thousands of dependency files.
160+
// Pre-filter all default exclude patterns at the findFiles level to avoid enumerating
161+
// thousands of files in build artifacts and dependencies.
161162
// '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/**');
163+
// Our manual filter below handles user-configured exclude patterns on top of these.
164+
const defaultExclude = '**/{node_modules,dist,build,out,.git,coverage}/**';
165+
const allFiles = await workspace.findFiles(include, defaultExclude);
164166

165167
// Manually filter files using exclude patterns
166168
// IMPORTANT: Get excludePatterns per file based on its workspace folder
@@ -199,8 +201,9 @@ export class BatchOrganizer {
199201
// Use RelativePattern to scope findFiles to the specific workspace folder
200202
// (plain string patterns search across ALL workspace roots in multi-root workspaces)
201203
const include = new RelativePattern(workspaceFolder, includeGlob);
202-
// Pass '**/node_modules/**' to findFiles to avoid enumerating thousands of dependency files.
203-
const allFiles = await workspace.findFiles(include, '**/node_modules/**');
204+
// Pre-filter all default exclude patterns at the findFiles level.
205+
const defaultExclude = '**/{node_modules,dist,build,out,.git,coverage}/**';
206+
const allFiles = await workspace.findFiles(include, defaultExclude);
204207

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

0 commit comments

Comments
 (0)