Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Keep trailing semicolons attached to the preceding word when wrapping (#54546)
Eric Holk2c237899f9b5
diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rsindex ffc433c671b..67e4a971344 100644--- a/crates/gpui/src/text_system/line_wrapper.rs+++ b/crates/gpui/src/text_system/line_wrapper.rs@@ -241,8 +241,9 @@ impl LineWrapper {// Some other known special characters that should be treated as word characters,// 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, '-' | '_' | '.' | '\'' | '’' | '‘' | '$' | '%' | '@' | '#' | '^' | '~' | ',' | '=' | ':') ||+ // `2^3`, `a~b`, `a=1`, `Self::new`, etc. Trailing punctuation like `,`, `.`, `:`, `;`+ // is included so it stays attached to the preceding word when wrapping.+ matches!(c, '-' | '_' | '.' | '\'' | '’' | '‘' | '$' | '%' | '@' | '#' | '^' | '~' | ',' | '=' | ':' | ';') ||// `⋯` character is special used in Zed, to keep this at the end of the line.matches!(c, '⋯')}@@ -837,6 +838,7 @@ mod tests {assert_word("$variable");assert_word("a=1");assert_word("Self::is_word_char");+ assert_word("on;");assert_word("more⋯");assert_word("won’t");assert_word("‘twas");