Don't override include/exclude defaults with false on remove#316755
Open
yogeshwaran-c wants to merge 1 commit into
Open
Don't override include/exclude defaults with false on remove#316755yogeshwaran-c wants to merge 1 commit into
yogeshwaran-c wants to merge 1 commit into
Conversation
Clicking "Remove" on a glob in `search.exclude` (and other include/exclude settings) in the Settings editor was writing `"<glob>": false` into settings.json when the glob existed as a schema default, instead of deleting the entry. For these settings (`search.exclude`, `files.readonlyInclude`, `workbench.localHistory.exclude`, etc.) `false` is meaningful: it overrides the default *and* suppresses any value inherited from a related setting. `search.exclude` inherits from `files.exclude`, so writing `false` to remove a default like `**/node_modules` made the glob be searched even when `files.exclude` still excludes it. Special-case `remove` to always delete the key from the user's value. `change` and `move` still write `false` over a default so the user's edit replaces the default. If a user wants to genuinely disable an inherited default (the previous behavior), they can still do so by editing settings.json directly. Fixes microsoft#249049
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @rzhao271Matched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Settings UI handling for include/exclude glob removal so removing a default glob deletes the scoped setting entry instead of writing a false override that can suppress inherited excludes.
Changes:
- Special-cases
removeevents inSettingIncludeExcludeRenderer. - Preserves existing default-override behavior for edit/change scenarios.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Clicking the "Remove" button on a glob in
search.exclude(and other include/exclude settings) in the Settings editor was writing"<glob>": falseintosettings.jsonwhen the glob matched a schema default, instead of removing the entry. Forsearch.excludethis broke the documented inheritance fromfiles.exclude.Fixes #249049.
Details
search.excludeinherits fromfiles.exclude. IngetExcludes()the two objects are merged with last-wins semantics, so afalsevalue insearch.excludeactively suppresses thetruevalue that would otherwise come fromfiles.exclude.SettingIncludeExcludeRenderer.onDidChangeIncludeExcludeinsrc/vs/workbench/contrib/preferences/browser/settingsTree.tstreated every non-addevent uniformly: if the original key was present in the setting'sdefaultValue, the renderer wrotefalsefor it ("delete a default by overriding it"). That logic predates theremove/change/move/resetdiscriminated event types, so it caught theremovecase too.Repro:
search.exclude. The schema defaults (**/node_modules,**/bower_components,**/*.code-search) are listed.**/node_modules.settings.jsonnow contains"search.exclude": { "**/node_modules": false }.node_modulesis searched even thoughfiles.excludestill excludes it.The fix special-cases
e.type === 'remove'and falls through to the existingdelete newValue[...]branch, so removing an entry simply deletes it from the user's scope value.changeandmovestill writefalseover a default - editing a default's text to something else continues to disable the original default, which is the expected behaviour when the user explicitly replaces it.If a user wants to genuinely disable an inherited default (the previous behaviour of the "Remove" button on a default value), they can still do so by editing
settings.jsondirectly.Test plan
Manual repro in a dev build:
search.excludein settings.json. Open Settings UI, click "X" on**/node_modules. Confirmsettings.jsondoes not gain a"**/node_modules": falseentry, and that the entry disappears from the UI then reappears (it is still a default)."**/foo": truetosearch.excludein settings.json. Open Settings UI, click "X" on**/foo. Confirm the key is removed fromsettings.json."**/foo": truetosearch.exclude. Open Settings UI, click the edit (pencil) on**/fooand change it to**/bar. Confirmsettings.jsonnow has"**/bar": trueand no"**/foo"entry.**/node_modulesand change it to**/baz. Confirmsettings.jsonhas"**/node_modules": falseand"**/baz": true(existing override-default-on-edit behaviour preserved).files.excludecontaining"**/node_modules": true, repeat step 1 and run a workspace search;node_modulesis correctly excluded.No automated test added:
onDidChangeIncludeExcludeis a private renderer method with substantial template/context/IInstantiationService dependencies and there are no existing tests forSettingIncludeExcludeRenderer. Building the harness for a single behavioural assertion would dwarf the fix.