editor: Support disabling semantic token highlighting via empty rules#52963
Merged
Veykril merged 4 commits intozed-industries:mainfrom Apr 2, 2026
Merged
editor: Support disabling semantic token highlighting via empty rules#52963Veykril merged 4 commits intozed-industries:mainfrom
Veykril merged 4 commits intozed-industries:mainfrom
Conversation
Contributor
Author
Member
|
/cherry-pick preview |
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 2, 2026
…#52963) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #52882, should help #52723 According to the [Zed documentation](https://zed.dev/docs/semantic-tokens#example-disabling-a-token-type), users should be able to disable semantic highlighting for a specific token type by adding an empty rule in `settings.json`. However, the current implementation fails to respect this because its merging logic allows lower-priority default styles to "leak through" even when a matching high-priority rule is empty. This makes it impossible to selectively disable semantic tokens to reveal the underlying Tree-sitter highlighting when using "semantic_tokens": "combined". This is particularly problematic for extensions that provide specialized Tree-sitter queries which are currently being obscured by less desirable semantic tokens(#52723). This PR fixes the logic to ensure that a completely empty high-priority rule acts as an opaque override, correctly disabling semantic styling for that token type and allowing Tree-sitter highlighting to show through as intended. Release Notes: - Fixed a bug where semantic token highlighting could not be disabled via empty rules in `settings.json`.
Contributor
|
🍒💥 Cherry-pick did not succeed |
piper-of-dawn
pushed a commit
to piper-of-dawn/zed
that referenced
this pull request
Apr 25, 2026
…zed-industries#52963) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes zed-industries#52882, should help zed-industries#52723 According to the [Zed documentation](https://zed.dev/docs/semantic-tokens#example-disabling-a-token-type), users should be able to disable semantic highlighting for a specific token type by adding an empty rule in `settings.json`. However, the current implementation fails to respect this because its merging logic allows lower-priority default styles to "leak through" even when a matching high-priority rule is empty. This makes it impossible to selectively disable semantic tokens to reveal the underlying Tree-sitter highlighting when using "semantic_tokens": "combined". This is particularly problematic for extensions that provide specialized Tree-sitter queries which are currently being obscured by less desirable semantic tokens(zed-industries#52723). This PR fixes the logic to ensure that a completely empty high-priority rule acts as an opaque override, correctly disabling semantic styling for that token type and allowing Tree-sitter highlighting to show through as intended. Release Notes: - Fixed a bug where semantic token highlighting could not be disabled via empty rules in `settings.json`.
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.



Self-Review Checklist:
Closes #52882, should help #52723
According to the Zed documentation, users should be able to disable semantic highlighting for a specific token type by adding an empty rule in
settings.json.However, the current implementation fails to respect this because its merging logic allows lower-priority default styles to "leak through" even when a matching high-priority rule is empty. This makes it impossible to selectively disable semantic tokens to reveal the underlying Tree-sitter highlighting when using "semantic_tokens": "combined". This is particularly problematic for extensions that provide specialized Tree-sitter queries which are currently being obscured by less desirable semantic tokens(#52723).
This PR fixes the logic to ensure that a completely empty high-priority rule acts as an opaque override, correctly disabling semantic styling for that token type and allowing Tree-sitter highlighting to show through as intended.
Release Notes:
settings.json.