editor: Fix multi-line cursor expansion when multi-byte characters are involved#51780
Merged
SomeoneToIgnore merged 6 commits intozed-industries:mainfrom Mar 19, 2026
Merged
Conversation
3 tasks
Contributor
Author
|
Brought in the Commits from my other PR, tldr: helix's multiline selection system faced the same problem as the main editor version, I fixed the helix version and tried to refactor it a bit to make things nicer. Behavior Before: broken_helix.movBehavior After: fixed_helix.mov
|
Contributor
|
Oh, seems like we need a formatter pass to merge it, would you be able to do so? |
Contributor
Author
|
yes will do rn. |
Contributor
|
Thanks for this fix! The multi-byte alignment issue was a real bug and the UTF-16 approach is the right call. I pushed one small refinement on top: a |
AmaanBilwar
pushed a commit
to AmaanBilwar/zed
that referenced
this pull request
Mar 20, 2026
…e involved (zed-industries#51780) Closes zed-industries#51740 The multi-line cursor expansion operates off of byte offsets, instead of character offsets, so multi-byte characters like the umlaut cause the multi-line cursors to be weirdly offset. To fix we just convert the expansion logic to rely on utf16 characters instead of bytes. before behavior: https://github.com/user-attachments/assets/320e24e9-0fdd-4d16-a9e8-ca17c9e21ff2 after behavior: https://github.com/user-attachments/assets/c4f0334b-dffc-4530-91ee-577b4fab75dd + test to verify functionality. Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [x] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - editor: fixed multi-line cursor expansion dealing with multi-byte characters. --------- Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
toshmukhamedov
pushed a commit
to toshmukhamedov/zed
that referenced
this pull request
Mar 20, 2026
…e involved (zed-industries#51780) Closes zed-industries#51740 The multi-line cursor expansion operates off of byte offsets, instead of character offsets, so multi-byte characters like the umlaut cause the multi-line cursors to be weirdly offset. To fix we just convert the expansion logic to rely on utf16 characters instead of bytes. before behavior: https://github.com/user-attachments/assets/320e24e9-0fdd-4d16-a9e8-ca17c9e21ff2 after behavior: https://github.com/user-attachments/assets/c4f0334b-dffc-4530-91ee-577b4fab75dd + test to verify functionality. Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [x] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - editor: fixed multi-line cursor expansion dealing with multi-byte characters. --------- Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
AmaanBilwar
pushed a commit
to AmaanBilwar/zed
that referenced
this pull request
Mar 23, 2026
…e involved (zed-industries#51780) Closes zed-industries#51740 The multi-line cursor expansion operates off of byte offsets, instead of character offsets, so multi-byte characters like the umlaut cause the multi-line cursors to be weirdly offset. To fix we just convert the expansion logic to rely on utf16 characters instead of bytes. before behavior: https://github.com/user-attachments/assets/320e24e9-0fdd-4d16-a9e8-ca17c9e21ff2 after behavior: https://github.com/user-attachments/assets/c4f0334b-dffc-4530-91ee-577b4fab75dd + test to verify functionality. Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [x] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - editor: fixed multi-line cursor expansion dealing with multi-byte characters. --------- Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
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.
Closes #51740
The multi-line cursor expansion operates off of byte offsets, instead of character offsets, so multi-byte characters like the umlaut cause the multi-line cursors to be weirdly offset. To fix we just convert the expansion logic to rely on utf16 characters instead of bytes.
before behavior:
broken.mov
after behavior:
fixed.mov
Before you mark this PR as ready for review, make sure that you have:
Release Notes: