-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Fix inlay hint hover highlight for multi-byte UTF-8 characters #44872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Veykril
merged 1 commit into
zed-industries:main
from
edlsh:fix/inlay-hint-hover-multibyte-chars
Jan 4, 2026
Merged
Fix inlay hint hover highlight for multi-byte UTF-8 characters #44872
Veykril
merged 1 commit into
zed-industries:main
from
edlsh:fix/inlay-hint-hover-multibyte-chars
Jan 4, 2026
Conversation
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
Fixes zed-industries#44812 The hover highlight for clickable inlay hints was not covering the last character when the label contained multi-byte UTF-8 characters (e.g., "→"). Root cause: `find_hovered_hint_part()` used `chars().count()` (character count) but `InlayOffset` is byte-based. For a label like "→ app/Livewire/UserProfile.php" (32 bytes, 30 chars), the calculated highlight range ended 2 bytes short. Changes: - Use `part.value.len()` (bytes) instead of `chars().count()` - Change boundary condition from `>` to `>=` for correct [start, end) semantics - Rename `hovered_character` to `offset_in_hint` for clarity - Add unit test with multi-byte characters reproducing the reported issue Release Notes: - Fixed inlay hint hover highlight not covering the last character when the label contains multi-byte UTF-8 characters (e.g., "→").
18102a0 to
ba7fbea
Compare
Veykril
approved these changes
Jan 4, 2026
Member
Veykril
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
rtfeldman
pushed a commit
that referenced
this pull request
Jan 5, 2026
## Summary Fixes #44812 The hover highlight for clickable inlay hints was not covering the last character when the label contained multi-byte UTF-8 characters (e.g., `→`). ## Problem When hovering over an inlay hint like `→ app/Livewire/UserProfile.php`, the highlight/underline stopped one character short, leaving the final character unhighlighted. **Root cause:** `find_hovered_hint_part()` in `hover_popover.rs` used `part.value.chars().count()` (character count) but `InlayOffset` wraps `MultiBufferOffset(pub usize)` which is byte-based. For a label like `→ app/Livewire/UserProfile.php`: - Byte length: 32 (the `→` character is 3 bytes in UTF-8) - Character count: 30 This mismatch caused the calculated highlight range to end 2 bytes short. ## Changes 1. **Use byte length instead of character count** (line 112): ```rust // Before (buggy) let part_len = part.value.chars().count(); // After (correct) let part_len = part.value.len(); ``` 2. **Fix boundary condition** (line 113): Changed `>` to `>=` for correct `[start, end)` range semantics when hovering at part boundaries. 3. **Rename variable** for clarity: `hovered_character` → `offset_in_hint` since it's a byte offset, not a character position. 4. **Add unit test** reproducing the exact scenario from the issue with multi-byte UTF-8 characters. ## Testing Added `test_find_hovered_hint_part_with_multibyte_characters` which: - Verifies the label `→ app/Livewire/UserProfile.php` has 32 bytes but 30 characters - Tests hovering at the last byte correctly returns the full range - Tests boundary behavior with multiple label parts containing multi-byte characters Release Notes: - Fixed inlay hint hover highlight not covering the last character when the label contains multi-byte UTF-8 characters
LivioGama
pushed a commit
to LivioGama/zed
that referenced
this pull request
Jan 20, 2026
…ndustries#44872) ## Summary Fixes zed-industries#44812 The hover highlight for clickable inlay hints was not covering the last character when the label contained multi-byte UTF-8 characters (e.g., `→`). ## Problem When hovering over an inlay hint like `→ app/Livewire/UserProfile.php`, the highlight/underline stopped one character short, leaving the final character unhighlighted. **Root cause:** `find_hovered_hint_part()` in `hover_popover.rs` used `part.value.chars().count()` (character count) but `InlayOffset` wraps `MultiBufferOffset(pub usize)` which is byte-based. For a label like `→ app/Livewire/UserProfile.php`: - Byte length: 32 (the `→` character is 3 bytes in UTF-8) - Character count: 30 This mismatch caused the calculated highlight range to end 2 bytes short. ## Changes 1. **Use byte length instead of character count** (line 112): ```rust // Before (buggy) let part_len = part.value.chars().count(); // After (correct) let part_len = part.value.len(); ``` 2. **Fix boundary condition** (line 113): Changed `>` to `>=` for correct `[start, end)` range semantics when hovering at part boundaries. 3. **Rename variable** for clarity: `hovered_character` → `offset_in_hint` since it's a byte offset, not a character position. 4. **Add unit test** reproducing the exact scenario from the issue with multi-byte UTF-8 characters. ## Testing Added `test_find_hovered_hint_part_with_multibyte_characters` which: - Verifies the label `→ app/Livewire/UserProfile.php` has 32 bytes but 30 characters - Tests hovering at the last byte correctly returns the full range - Tests boundary behavior with multiple label parts containing multi-byte characters Release Notes: - Fixed inlay hint hover highlight not covering the last character when the label contains multi-byte UTF-8 characters
LivioGama
pushed a commit
to LivioGama/zed
that referenced
this pull request
Jan 20, 2026
…ndustries#44872) ## Summary Fixes zed-industries#44812 The hover highlight for clickable inlay hints was not covering the last character when the label contained multi-byte UTF-8 characters (e.g., `→`). ## Problem When hovering over an inlay hint like `→ app/Livewire/UserProfile.php`, the highlight/underline stopped one character short, leaving the final character unhighlighted. **Root cause:** `find_hovered_hint_part()` in `hover_popover.rs` used `part.value.chars().count()` (character count) but `InlayOffset` wraps `MultiBufferOffset(pub usize)` which is byte-based. For a label like `→ app/Livewire/UserProfile.php`: - Byte length: 32 (the `→` character is 3 bytes in UTF-8) - Character count: 30 This mismatch caused the calculated highlight range to end 2 bytes short. ## Changes 1. **Use byte length instead of character count** (line 112): ```rust // Before (buggy) let part_len = part.value.chars().count(); // After (correct) let part_len = part.value.len(); ``` 2. **Fix boundary condition** (line 113): Changed `>` to `>=` for correct `[start, end)` range semantics when hovering at part boundaries. 3. **Rename variable** for clarity: `hovered_character` → `offset_in_hint` since it's a byte offset, not a character position. 4. **Add unit test** reproducing the exact scenario from the issue with multi-byte UTF-8 characters. ## Testing Added `test_find_hovered_hint_part_with_multibyte_characters` which: - Verifies the label `→ app/Livewire/UserProfile.php` has 32 bytes but 30 characters - Tests hovering at the last byte correctly returns the full range - Tests boundary behavior with multiple label parts containing multi-byte characters Release Notes: - Fixed inlay hint hover highlight not covering the last character when the label contains multi-byte UTF-8 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
Fixes #44812
The hover highlight for clickable inlay hints was not covering the last character when the label contained multi-byte UTF-8 characters (e.g.,
→).Problem
When hovering over an inlay hint like
→ app/Livewire/UserProfile.php, the highlight/underline stopped one character short, leaving the final character unhighlighted.Root cause:
find_hovered_hint_part()inhover_popover.rsusedpart.value.chars().count()(character count) butInlayOffsetwrapsMultiBufferOffset(pub usize)which is byte-based.For a label like
→ app/Livewire/UserProfile.php:→character is 3 bytes in UTF-8)This mismatch caused the calculated highlight range to end 2 bytes short.
Changes
Use byte length instead of character count (line 112):
Fix boundary condition (line 113): Changed
>to>=for correct[start, end)range semantics when hovering at part boundaries.Rename variable for clarity:
hovered_character→offset_in_hintsince it's a byte offset, not a character position.Add unit test reproducing the exact scenario from the issue with multi-byte UTF-8 characters.
Testing
Added
test_find_hovered_hint_part_with_multibyte_characterswhich:→ app/Livewire/UserProfile.phphas 32 bytes but 30 charactersRelease Notes: