Repository navigation
Add experimental opt-in to honor .gitignore in findFiles extension API - #316349
Merged
Osvaldo Ortega (osortega) merged 3 commits intoMay 14, 2026
Merged
Osvaldo Ortega (osortega) merged 3 commits into
Osvaldo Ortega (osortega) merged 3 commits into
Conversation
Adds search.experimental.useIgnoreFilesInFindFiles (default off). When enabled, the legacy workspace.findFiles extension API honors the user's search.useIgnoreFiles setting instead of always passing --no-ignore to ripgrep. Extensions that explicitly pass `null` as the exclude argument keep the documented unfiltered-results escape hatch. Also emits a new extHostFindFiles telemetry event from both findFiles and findFiles2 to size populations and measure impact before changing the default: - extensionId, apiKind, durationMs, resultCount, queryCount, cancelled, errored: per-call performance/outcome. - respectedIgnoreFiles: effective behavior for this call. - useIgnoreFilesLocalRequested + excludeWasNull: extension intent captured at the API boundary, so we can distinguish callers that explicitly asked for unfiltered results from those that simply did not specify.
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an experimental setting to let the legacy workspace.findFiles extension API honor .gitignore (via the user’s search.useIgnoreFiles setting) instead of always forcing ripgrep’s --no-ignore, and introduces telemetry to measure impact and guide a potential future default change.
Changes:
- Added
search.experimental.useIgnoreFilesInFindFiles(off by default) to optionally stop forcing--no-ignorefor legacyfindFiles, while preserving theexclude: null“unfiltered results” escape hatch. - Added per-call telemetry event
extHostFindFilesfor bothfindFilesandfindFiles2including duration, counts, and effective ignore behavior. - Wired
ExtHostConfigurationto provide a config provider toExtHostWorkspaceto allow synchronous reads of the experimental setting.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/search/browser/search.contribution.ts |
Registers the new experimental search setting controlling legacy findFiles ignore-file behavior. |
src/vs/workbench/api/common/extHostWorkspace.ts |
Implements the opt-in behavior for legacy findFiles and adds extHostFindFiles telemetry around file-search execution. |
src/vs/workbench/api/common/extHostConfiguration.ts |
Pushes the configuration provider into ExtHostWorkspace post-init to enable synchronous setting reads. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/api/common/extHostWorkspace.ts:546
- Telemetry is skipped when the token is already cancelled because
_findFilesImplreturns early before the try/finally that reports the event. The PR description says telemetry is emitted once per call (including cancelled calls), so this path should still logcancelled: true(and likelydurationMs: 0,resultCount: 0,queryCount: 0).
if (token.isCancellationRequested) {
return Promise.resolve([]);
}
- Files reviewed: 3/3 changed files
- Comments generated: 2
…/finally - Factor the user's search.useIgnoreFiles setting into respectedIgnoreFiles so the telemetry reflects the effective ripgrep behavior when disregardIgnoreFiles is undefined (the query builder defaults from the setting in that case). - Hoist telemetry state to the top of _findFilesImpl and wrap the entire function body in try/catch/finally so the early cancellation return and the invalid-pattern throw still emit a telemetry event with cancelled / errored set.
findFiles now emits telemetry, so tests fail with 'Cannot read properties of undefined (reading $publicLog2)' when MainThreadTelemetry isn't registered on the test RPC protocol.
Osvaldo Ortega (osortega)
marked this pull request as ready for review
May 14, 2026 02:41
Osvaldo Ortega (osortega)
enabled auto-merge (squash)
May 14, 2026 02:41
roblourens
approved these changes
May 14, 2026
Osvaldo Ortega (osortega)
deleted the
osortega/findfiles-respect-ignore-experimental
branch
May 14, 2026 03:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #305544
Summary
The legacy
workspace.findFilesextension API currently passes--no-ignoreto ripgrep unconditionally — every call walks past.gitignore, even when the user hassearch.useIgnoreFiles: true. In worktree-heavy or monorepo workspaces this can fan out into millions of files and stall the workbench, especially on macOS.This PR adds a low-risk lever and measurement so we can:
Changes
Setting
search.experimental.useIgnoreFilesInFindFiles(boolean, defaultfalse, taggedexperimental).findFilesalways passes--no-ignore.findFileshonors the user'ssearch.useIgnoreFilessetting, except when the extension explicitly passesnullas theexcludeargument (the documented "unfiltered results" escape hatch is preserved).findFiles2is unchanged — it already acceptsuseIgnoreFilesfrom the extension and is the recommended path going forward.