Skip to content

Add experimental opt-in to honor .gitignore in findFiles extension API - #316349

Merged
Osvaldo Ortega (osortega) merged 3 commits into
mainfrom
osortega/findfiles-respect-ignore-experimental
May 14, 2026
Merged

Osvaldo Ortega (osortega) merged 3 commits into
mainfrom
osortega/findfiles-respect-ignore-experimental

Conversation

@osortega

@osortega Osvaldo Ortega (osortega) commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: #305544

Summary

The legacy workspace.findFiles extension API currently passes --no-ignore to ripgrep unconditionally — every call walks past .gitignore, even when the user has search.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:

  1. Unblock affected users today via an opt-in setting.
  2. Decide later whether to flip the default, backed by data instead of guesses.

Changes

Setting

search.experimental.useIgnoreFilesInFindFiles (boolean, default false, tagged experimental).

  • Off (default): today's behavior — findFiles always passes --no-ignore.
  • On: findFiles honors the user's search.useIgnoreFiles setting, except when the extension explicitly passes null as the exclude argument (the documented "unfiltered results" escape hatch is preserved).

findFiles2 is unchanged — it already accepts useIgnoreFiles from the extension and is the recommended path going forward.

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.
Copilot AI review requested due to automatic review settings May 14, 2026 02:05
@github-actions

github-actions Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: b07b3278 Current: 51d15de6

Changed (2)

agentSessionsViewer/ClaudeProvider/Dark
Before After
before after
agentSessionsViewer/ClaudeProvider/Light
Before After
before after

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-ignore for legacy findFiles, while preserving the exclude: null “unfiltered results” escape hatch.
  • Added per-call telemetry event extHostFindFiles for both findFiles and findFiles2 including duration, counts, and effective ignore behavior.
  • Wired ExtHostConfiguration to provide a config provider to ExtHostWorkspace to 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 _findFilesImpl returns 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 log cancelled: true (and likely durationMs: 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.
@osortega
Osvaldo Ortega (osortega) merged commit b02737d into main May 14, 2026
25 checks passed
@osortega
Osvaldo Ortega (osortega) deleted the osortega/findfiles-respect-ignore-experimental branch May 14, 2026 03:30
@vs-code-engineering vs-code-engineering Bot added this to the 1.121.0 milestone May 14, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jun 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.113.0 regression: unbounded ripgrep processes freeze macOS when worktrees exist

3 participants