From c8a77aeb895cf25d6315e6c4a9c95665a1a54a1f Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 08:45:53 +0000 Subject: [PATCH] git_ui: Fix utf8 panic in `compress_commit_diff` (#43972) (cherry-pick to preview) (#43973) Cherry-pick of #43972 to preview ---- Fixes ZED-3QG Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored-by: Lukas Wirth --- crates/git_ui/src/git_panel.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 4a5cd56ec90fd95fe94d55edfdeb7e2114fea820..4e9dfce63442153bd27221bd5bb75834c1791193 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -1950,7 +1950,7 @@ impl GitPanel { .lines() .map(|line| { if line.len() > 256 { - format!("{}...[truncated]\n", &line[..256]) + format!("{}...[truncated]\n", &line[..line.floor_char_boundary(256)]) } else { format!("{}\n", line) } @@ -5897,7 +5897,7 @@ mod tests { #[test] fn test_compress_diff_truncate_long_lines() { - let long_line = "a".repeat(300); + let long_line = "🦀".repeat(300); let diff = indoc::formatdoc! {" --- a/file.txt +++ b/file.txt