From 46b08f9d7d6f68875cee692f4ae88c902a05ab4a Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 19 May 2026 05:46:05 -0600 Subject: [PATCH] gpui: Trim trailing whitespace and punctuation before ellipsis (#57106) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When truncating text at the end with an ellipsis, the truncation point can land right after a space or punctuation character, producing results like `"some text …"` or `"some text-…"`. This trims trailing whitespace and ASCII punctuation from the truncated prefix before appending the ellipsis affix, so you get clean results like `"some text…"` instead. Release Notes: - Improved text truncation to avoid trailing spaces or punctuation before the ellipsis. --- crates/gpui/src/text_system/line_wrapper.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rs index 67e4a97134..0524bad84f 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);