Fix schema deselection through the schema picker - #1283
Merged
shin19991207 merged 2 commits intoSep 21, 2026
Merged
Conversation
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Merged
2 tasks
datho7561
approved these changes
Sep 18, 2026
datho7561
left a comment
Contributor
There was a problem hiding this comment.
Looks good and works well! Thanks, Morgan!
Found one edge case that works a bit odd but I think it's still good to merge. Feel free to merge if you agree.
Here's the edge case:
Disable schema detection through yaml.disableSchemaDetection using a glob, then create a file that matches the glob. Try to set the schema for the file using the schema picking UI.
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.
What does this PR do?
Preserve schema globs and configuration scopes when deselecting schemas
Previously, the schema picker operated on the effective merged
yaml.schemasvalue. This caused two problems:*.yaml, deselecting the schema for one matching file did not remove the association because the original glob continued to match that fileThe picker also used
yaml.disableSchemaDetectionwhen "No JSON Schema" was selected. That setting suppresses all detected/configured schemas for a matching file, rather than only the schema the user deselected.This PR changes the picker behavior:
{ "yaml.schemas": { "https://example.com/schema.json": [ "*.yaml", "!file:///path/to/test.yaml" ] } }yaml.disableSchemaDetectionThe
yaml.schemasREADME documentation and VS Code setting description now document exclusion patterns.Support for negated schema file-match patterns is provided by redhat-developer/yaml-language-server#1345
What issues does this PR fix or reference?
Related to #1212
The issue reports that when schemas configured at the User and Workspace scopes target the same files, an unexpected schema may be selected (from my testing, all are selected). It proposes prioritizing those schemas based on their versions.
This PR does not implement schema-version priority or change how settings from different scopes are merged. Configuration scope precedence and effective merged setting values are managed by VS Code: https://code.visualstudio.com/docs/configure/settings
The schema picker UI already supports choosing a schema version when the schema explicitly provides version metadata. However, assigning priority based on arbitrary local schema filenames would not be reliable (IMO). For example, there is no dependable way to determine that
schema-1.1.0.jsonandschema-1.2.0.jsonrepresent different versions of the same logical schema. Inferring schema identity and semantic-version ordering from arbitrary paths or URIs could produce incorrect results.However, while investigating the issue, I found the schema-picker issues. This PR fixes the issues. User reporting the original issue can therefore uses the schema picker UI to select their preferred schema now.
Is it tested? How?
Manual test 1: Basic select/deselect
Create a file named
test.yaml:Open the file and click the schema status bar item.
Select any schema, such as one from SchemaStore.
Verify
.vscode/settings.jsoncontains:{ "yaml.schemas": { "https://the-schema-url": "file:///path/to/test.yaml" } }Open the schema picker again and choose No JSON Schema.
Verify the
yaml.schemasentry is removed.Verify
yaml.disableSchemaDetectionis unchanged and does not receive the file URI.Manual test 2: Negation with a glob
Add the following Workspace setting:
{ "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": "*.yaml" } }Open
test.yaml.Verify the status bar shows
github-workflow.Open the schema picker and deselect
github-workflow.Verify the setting becomes:
{ "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": [ "*.yaml", "!file:///path/to/test.yaml" ] } }Open another YAML file, such as
other.yaml.Verify
other.yamlstill usesgithub-workflow.Manual test 3: Configuration-scope independence
Add the following User setting:
{ "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": "*.yaml" } }Add a different schema to
.vscode/settings.json:{ "yaml.schemas": { "https://json.schemastore.org/docker-compose.json": "*.yaml" } }Open
test.yaml.Verify both schemas are active.
Open the schema picker.
Deselect
docker-composewhile keepinggithub-workflowselected.Verify the User setting is unchanged.
Verify only the Workspace setting is updated:
{ "yaml.schemas": { "https://json.schemastore.org/docker-compose.json": [ "*.yaml", "!file:///path/to/test.yaml" ] } }