git_ui: Fix utf8 panic in `compress_commit_diff` (#43972) (cherry-pick to preview) (#43973)

zed-zippy[bot] and Lukas Wirth created

Cherry-pick of #43972 to preview

----
Fixes ZED-3QG

Release Notes:

- N/A *or* Added/Fixed/Improved ...

Co-authored-by: Lukas Wirth <lukas@zed.dev>

Change summary

crates/git_ui/src/git_panel.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Detailed changes

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