mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-02 05:20:29 +01:00
f0210f1621
Replaces the `is_word_char` list with Unicode line breaking ([UAX #<!-- -->14](https://www.unicode.org/reports/tr14/)) using the `icu_segmenter` crate. `is_word_char` can't express line breaks that depend on both neighboring characters, so currently wrapped lines sometimes start with `/` or `?`, and some emojis like 👍🏽, 🇯🇵, and 👩💻 get incorrectly split across lines: https://github.com/user-attachments/assets/2a8a9eee-11c9-4143-b56c-3a2b4621af9a This generalizes the tweaks from #11296, #17590, #35724, #37019, #37024, #45160, #51659, #51973, #54546, #59775, and #62743, and supersedes #62345 and #63983. Important to note: - This allows hyphenated words to break after the hyphen which is a behavior change. I believe UAX #<!-- -->14 does permit tweaking this in case we want to keep the current behavior, by filtering those out of the `break_indices` return value. - Obviously this isn't quite as performant as `is_word_char`, but it seems to still be plenty fast enough, as I wasn't able to come up with a contrived case where this causes noticeable performance issues. ## 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) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Improved text wrapping to follow Unicode line breaking rules. - [GPUI] Improved text wrapping to follow Unicode line breaking rules. --------- Co-authored-by: Noritada Kobayashi <noritada.kobayashi@gmail.com> Co-authored-by: Lukas Wirth <lukas@zed.dev>