Commit 9554ea5
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | 122 | | |
133 | 123 | | |
134 | 124 | | |
135 | | - | |
| 125 | + | |
136 | 126 | | |
137 | 127 | | |
138 | 128 | | |
| |||
0 commit comments