From 8d0961074899a1dac48405a40ae49500b81e20ed Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 2 Dec 2025 09:31:44 +0100 Subject: [PATCH] git_ui: Fix utf8 panic in `compress_commit_diff` (#43972) Fixes ZED-3QG Release Notes: - N/A *or* Added/Fixed/Improved ... --- 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 bc71c8249f90b6b5c2994e99077f9f27129eae6d..8579cafa58a22ea6d182f23b753d3b1a365f37fa 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) } @@ -5910,7 +5910,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