Skip to content

Support exclude exceptions in the Settings editor and settings.json - #345013

Draft
Logan Ramos (lramos15) wants to merge 15 commits into
mainfrom
agents/vscode-negated-globs-settings-ui
Draft

Logan Ramos (lramos15) wants to merge 15 commits into
mainfrom
agents/vscode-negated-globs-settings-ui

Conversation

@lramos15

Copy link
Copy Markdown
Member

Follow-up to #344980 (stacked on it), split out to keep the core change focused. Refs #869.

Changes

  • Settings editor: the exclude list widget for files.exclude / search.exclude shows !-prefixed keys as exceptions ("Do not exclude files matching …") and adds an Add Exception button that starts a new pattern with !.
  • settings.json diagnostics for exclude settings:
    • "pattern": false that does not disable a pattern from another scope: Info, with a Convert to Exception quick fix (skipped when the !pattern key already exists).
    • Absolute exceptions such as "!/workspace/keep.js": true: Warning, because exceptions are folder-relative and absolute ones are ignored.
    • Exceptions starting with **: Info, because search walks the whole folder to find them.

How to test

  1. Open the Settings editor → Files: Exclude, click Add Exception, enter !node_modules/@types.
  2. In settings.json, add "files.exclude": { "foo": false, "!/abs/path": true, "!**/Scripts": true } and check the markers and the quick fix on "foo": false.

Validation

  • npm run typecheck-client: passed
  • npm run eslint -- <changed preferences files>: passed
  • ./scripts/test.sh --runGlob "**/contrib/preferences/test/**/*.test.js": passed (135 tests)

A `!`-prefixed key in files.exclude or search.exclude now marks an exception: matching paths and everything inside them are not excluded, even when another pattern or .gitignore excludes them. Exceptions never add exclusions and do not depend on key order, so settings scopes still merge as before, and `false` keeps disabling a key. Expressions without exceptions parse exactly as before.

The explorer shows the folders that lead to an exception, search re-includes excepted paths with an extra ripgrep run per exception root, and the Settings editor gains an Add Exception action plus a quick fix for `"pattern": false` entries that disable nothing. Other glob settings and the extension API keep treating `!` literally.

Fixes #869

Co-authored-by: Copilot <[email protected]>
- Do not let exception-run text matches that are filtered out use up the result limit
- Evaluate web search excludes once, with folder exceptions, instead of re-checking global excludes per file
- Treat brace alternatives with a path separator as variable length when pruning folders
- Apply absolute exceptions that start with the searched folder in ripgrep runs and in the post-filter
- Do not infer existence from the exit code of an exception run
- Keep exceptions relative in the breadcrumbs picker
- Resolve exception run roots to their casing on disk and skip roots that pass through a symbolic link when links are not followed
- Only remember excepted paths of the main ripgrep run for deduplication, and avoid repeated configuration lookups in settings.json diagnostics

Co-authored-by: Copilot <[email protected]>
Exceptions no longer look into version control folders such as .git unless an exception names them, in search runs and in the explorer, and settings.json flags exceptions that make search walk the whole folder.

Co-authored-by: Copilot <[email protected]>
- Keep files below excluded folders hidden in the breadcrumbs picker when it shows a folder that leads to an exception
- Apply relative and absolute exceptions in the quick open history matcher, whichever path the exclude matched
- Do not offer converting a false pattern into an existing exception key, and inspect local and remote user settings separately
- Only describe ! patterns as exceptions in the Settings editor for settings that support them
- Resolve exception run roots case-insensitively when globs ignore case, starting from the closest unambiguous folder
- Treat an absolute exception for the searched folder itself as the whole folder

Co-authored-by: Copilot <[email protected]>
- Search the paths that exceptions re-include with a single pruned ripgrep
  run per folder (`-g '!*'` plus the path components of each exception)
  instead of one run per literal prefix, which removes root resolution for
  casing, symbolic links and missing folders
- Share one tree walk helper, `evaluateExcludeTreeEntry`, between the
  explorer, breadcrumbs, file walkers and search providers
- Only support folder-relative exceptions; absolute `!` keys are ignored
- Move the Settings editor and settings.json changes to a follow-up PR

Co-authored-by: Copilot <[email protected]>
- The exclude list widget in the Settings editor shows `!` keys as
  exceptions, with a dedicated "Add Exception" button
- settings.json flags `"pattern": false` entries that disable nothing,
  with a quick fix to convert them into an exception, and flags
  exceptions that are ignored because they are absolute or that make
  search walk the whole folder

Co-authored-by: Copilot <[email protected]>
Whitelisting the folders that lead to an exception with globs such as
`**` listed every file, so a text search read all files when an exception
starts with `**`. Folders that lead to an exception now use folder-only
globs, and runs for exceptions that can match at any depth only whitelist
the exceptions.

Co-authored-by: Copilot <[email protected]>
- Limit accepted text search results to the default limit when the query
  does not specify one, so results of exclude exception runs, which are not
  limited by ripgrep, stay bounded and report `limitHit`
- Expand brace groups when finding the version control folders that an
  exception names, so `!{.git,.hg}/hooks` looks into both folders
- Test that exceptions with a `..` segment do not search outside the folder

Co-authored-by: Copilot <[email protected]>
…-globs-explanation

# Conflicts:
#	src/vs/workbench/test/common/resources.test.ts
- Check text search results of the exception run against the exceptions,
  because ripgrep globs can match more than VS Code globs (`**.js`), and
  skip folders of the query that are inside the searched folder, as file
  search does
- Keep version control folders excluded under an exception unless an
  exception names them, so the explorer and the JS search paths agree
  with ripgrep
- Traverse folders for exceptions with a globstar inside braces, such as
  `{**,foo}/keep.txt`
- Apply folder-relative exceptions when an absolute exclude pattern
  matches in quick open history
- Record the exclude exception time before the search completes

Co-authored-by: Copilot <[email protected]>
- Only traverse every folder for a brace alternative that is a globstar,
  such as `{**,foo}`; `**` within a segment, as in `**.js`, matches a
  single segment
- Find the folders of a text query that are inside a folder with the
  glob case setting, as file search does, so differently cased nested
  folders are skipped by the exclude exception run

Co-authored-by: Copilot <[email protected]>
Explorer Find dropped folder hits that `.gitignore` hides even when the
explorer shows them because an exclude exception matches beneath them.

Co-authored-by: Copilot <[email protected]>
Base automatically changed from agents/vscode-negated-globs-explanation to main October 30, 2026 16:33

This branch has not been deployed

No deployments
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.

1 participant