Skip to content

feat: respect built-in files.exclude / search.exclude (#31)#83

Merged
dawsbot merged 3 commits into
masterfrom
feat/31-respect-builtin-excludes
Jul 7, 2026
Merged

feat: respect built-in files.exclude / search.exclude (#31)#83
dawsbot merged 3 commits into
masterfrom
feat/31-respect-builtin-excludes

Conversation

@dawsbot

@dawsbot dawsbot commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What

Adds a new relativePath.useBuiltInExcludes setting so the picker can also honor VS Code's built-in files.exclude and/or search.exclude, letting users avoid duplicating those globs in relativePath.ignore.

Closes #31.

The setting

relativePath.useBuiltInExcludes (string enum, default "none"):

Value Behavior
none (default) Only relativePath.ignore (unchanged behavior)
files Also hide files matched by files.exclude
search Also hide files matched by search.exclude
both Also hide files matched by either

This matches the API shape requested in the issue thread (choose to follow both or either).

How it works

  • collectBuiltInExcludes() reads the enabled globs (value === true) from the chosen source(s). Entries set to false (a user re-including a path) and { when } sibling clauses are skipped, since we can't cheaply resolve the latter.
  • The built-in settings write folders as **/node_modules (no trailing /**). findFiles prunes that folder's contents, but the file-creation watcher matches file paths directly, so for each folder glob we also add the /** descendant form. This keeps files created after the initial scan inside an excluded folder out of the cache. Appending /** to a file-name pattern like **/*.pyc is harmless (it just never matches).
  • The merged list feeds both the findFiles scan and the creation watcher, so they stay consistent.
  • The config watcher now rescans when the mode changes, or when files.exclude / search.exclude change while the mode is active.
  • buildExcludeGlob now dedupes and emits a single glob bare (a one-item brace {a} is not alternation, so it would otherwise be read literally).

Defaults to "none", so existing users see no change unless they opt in.

Testing

  • 10 new unit tests covering collectBuiltInExcludes (each mode, true-only filtering, when-clause skipping, descendant-form handling) and the buildExcludeGlob dedupe / single-glob cases.
  • Full suite: 42 pass, 0 fail. tsc typechecks clean.

The pure exclude-merging logic is fully unit-tested; the VS Code wiring (findFiles / watcher / config-change rescan) compiles and follows the existing patterns. It was verified via typecheck + unit tests rather than launching the Extension Development Host, which needs an interactive GUI.

🤖 Generated with Claude Code

dawsbot and others added 3 commits July 6, 2026 23:27
Add a `relativePath.useBuiltInExcludes` setting so the picker can also
honor VS Code's built-in `files.exclude` and/or `search.exclude`, letting
users avoid duplicating those globs in `relativePath.ignore`.

- collectBuiltInExcludes() reads the enabled globs (value === true) from
  either/both settings and, for folder-style globs, adds the `/**`
  descendant form so the file-creation watcher matches contents the same
  way findFiles prunes them.
- The merged list feeds both the findFiles scan and the watcher.
- The config watcher rescans when the mode changes, or when
  files.exclude / search.exclude change while the mode is active.
- buildExcludeGlob now dedupes and emits a single glob bare (a one-item
  brace is not alternation).

Defaults to "none", so existing behavior is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Honor VS Code's built-in files.exclude and search.exclude out of the box,
so users get sensible excludes without duplicating them into
relativePath.ignore. Set the new setting to "none" to restore the prior
behavior of using only relativePath.ignore.

This changes default behavior: files under files.exclude / search.exclude
are now hidden from the picker unless opted out.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…oolean

The four-value enum over-promised. VS Code's findFiles always applies
files.exclude to the scan (short of a null exclude, which would also drop
our own ignore globs), so the "none" and "files" modes were misleading:
files.exclude can't be turned off for the scan, and adding it there is a
no-op. The only genuine user choice is whether to also honor search.exclude,
which findFiles never applies on its own.

- New boolean `relativePath.respectSearchExclude` (default true) gates
  search.exclude.
- files.exclude is now always merged into the ignore globs so the file
  creation watcher stays consistent with the scan VS Code already prunes.
- collectBuiltInExcludes(mode, files, search) becomes the single-source
  collectExcludeGlobs(exclude).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dawsbot dawsbot merged commit ba84c3b into master Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Respect search.exclude

1 participant