From 55a59ca17d44ebf12fee6edc07ac9ee3a1e33268 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Thu, 19 Mar 2026 13:52:39 -0700 Subject: [PATCH] gpui: Treat typographic apostrophes as word characters for line wrapping (#51973) The line wrapper's `is_word_char` function included the ASCII apostrophe (U+0027) but not the typographic right single quotation mark `'` (U+2019) or left single quotation mark `'` (U+2018). When Markdown rendering produces curly quotes, words like `won't` were being split at the apostrophe during line wrapping, producing `won` at the end of one line and `'t` at the start of the next. This adds both typographic quote characters to `is_word_char` so they are treated the same as the ASCII apostrophe. Release Notes: - Fixed line wrapping splitting words at typographic apostrophes (e.g. "won't" breaking as "won" / "'t"). --- crates/gpui/src/text_system/line_wrapper.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rs index 9a7d10133bb9bd57b86c3e08e1a21e47fec38b96..ffc433c671ba8f13aff1655b0aed91f95d0ff22a 100644 --- a/crates/gpui/src/text_system/line_wrapper.rs +++ b/crates/gpui/src/text_system/line_wrapper.rs @@ -240,9 +240,9 @@ impl LineWrapper { matches!(c, '\u{0980}'..='\u{09FF}') || // Some other known special characters that should be treated as word characters, - // e.g. `a-b`, `var_name`, `I'm`, '@mention`, `#hashtag`, `100%`, `3.1415`, + // e.g. `a-b`, `var_name`, `I'm`/`won’t`, '@mention`, `#hashtag`, `100%`, `3.1415`, // `2^3`, `a~b`, `a=1`, `Self::new`, etc. - matches!(c, '-' | '_' | '.' | '\'' | '$' | '%' | '@' | '#' | '^' | '~' | ',' | '=' | ':') || + matches!(c, '-' | '_' | '.' | '\'' | '’' | '‘' | '$' | '%' | '@' | '#' | '^' | '~' | ',' | '=' | ':') || // `⋯` character is special used in Zed, to keep this at the end of the line. matches!(c, '⋯') } @@ -838,6 +838,8 @@ mod tests { assert_word("a=1"); assert_word("Self::is_word_char"); assert_word("more⋯"); + assert_word("won’t"); + assert_word("‘twas"); // Space assert_not_word("foo bar");