# editor: Fix multi-line cursor expansion when multi-byte characters are involved \(\#51780\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/d94aa26ac53c488fab4e4293c973ad87a5e674c9)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: d94aa26ac53c488fab4e4293c973ad87a5e674c9

Requested commit: d94aa26ac53c488fab4e4293c973ad87a5e674c9

Commit: d94aa26ac53c488fab4e4293c973ad87a5e674c9

Tree: 8bce9796e054b4c2eafe0963d3a0e02cec8093c0

Author: Finn Eitreim

Committer: GitHub

## Message

```
editor: Fix multi-line cursor expansion when multi-byte characters are involved (#51780)

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:


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>
```

## Parents

- [e314c023b37cbc5583f8e7ab042bd88bee63213b](https://git.cafe/gitcafe/zed/commit/e314c023b37cbc5583f8e7ab042bd88bee63213b?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/d94aa26ac53c488fab4e4293c973ad87a5e674c9?format=markdown)
