Skip to content

Commit 9554ea5

Browse files
authored
Distinguish parameters from normal variables in semantic token highlighting (#60949)
# Objective Closes #60928 Currently, only the declaration of parameters in a function header is highlighted as `variable.parameter`. Inside the function body, parameters are highlighted as normal variables, making them indistinguishable from local variables. This PR ensures consistent highlighting for parameters throughout their entire scope, helping developers distinguish between function inputs and locally defined variables. ## Solution - Updated the `default_semantic_token_rules.json`: when the token type is `parameter`, no matter what token modifiers are, it is now mapped to `variable.parameter` highlight style. ## Testing Tested locally with Rust. The improvement in visual hierarchy is demonstrated in the comparison below. ## 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 adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase | Before | After | | :---: | :---: | | <img width="1178" height="400" alt="before" src="https://github.com/user-attachments/assets/90a01543-2dcc-41e0-a2a3-f8020c6d77ee" /> | <img width="1194" height="387" alt="after" src="https://github.com/user-attachments/assets/c81ba273-2ea7-4d38-b7df-a6069c09c28a" />| --- Release Notes: - Improved semantic token highlighting to distinguish function parameters from local variables.
1 parent 7a3a823 commit 9554ea5

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

assets/settings/default_semantic_token_rules.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,10 @@
119119
"style": ["type"],
120120
},
121121
// References
122-
{
123-
"token_type": "parameter",
124-
"token_modifiers": ["declaration"],
125-
"style": ["variable.parameter"]
126-
},
127-
{
128-
"token_type": "parameter",
129-
"token_modifiers": ["definition"],
130-
"style": ["variable.parameter"]
131-
},
132122
{
133123
"token_type": "parameter",
134124
"token_modifiers": [],
135-
"style": ["variable"],
125+
"style": ["variable.parameter"],
136126
},
137127
{
138128
"token_type": "variable",

0 commit comments

Comments
 (0)