Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Trim trailing whitespace and punctuation before ellipsis (#57106)

Conrad Irwin46b08f9d7d6f
diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rs
index 67e4a971344..0524bad84f0 100644
--- a/crates/gpui/src/text_system/line_wrapper.rs
+++ b/crates/gpui/src/text_system/line_wrapper.rs
@@ -201,9 +201,11 @@ impl LineWrapper {
"{truncation_affix}{}",
&line[line.ceil_char_boundary(truncate_ix + 1)..]
)),
- TruncateFrom::End => {
- SharedString::from(format!("{}{truncation_affix}", &line[..truncate_ix]))
- }
+ TruncateFrom::End => SharedString::from(format!(
+ "{}{truncation_affix}",
+ line[..truncate_ix]
+ .trim_end_matches(|c: char| c.is_whitespace() || c.is_ascii_punctuation())
+ )),
};
let mut runs = runs.to_vec();
update_runs_after_truncation(&result, truncation_affix, &mut runs, truncate_from);