From 9e2c415abb11144b1bd4054b1bc071e3bc69e7f7 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Sun, 25 Jan 2026 22:05:04 -0500 Subject: [PATCH] git: Fix incorrect spacers for added or deleted files at the end of the multibuffer (#47525) Release Notes: - N/A --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- crates/editor/src/display_map/block_map.rs | 2 +- crates/editor/src/split.rs | 76 ++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index f5abdfa21978b4e13dbebc6bc8cfd2aade5837c9..a7cd0c88e8c48599989669f9ece9fecc8b9b5f60 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -666,7 +666,7 @@ impl BlockMap { let mut my_start = wrap_snapshot.make_wrap_point(my_start, Bias::Left); let mut my_end = wrap_snapshot.make_wrap_point(my_end, Bias::Left); - if my_end.column() > 0 { + if my_end.column() > 0 || my_end == wrap_snapshot.max_point() { *my_end.row_mut() += 1; *my_end.column_mut() = 0; } diff --git a/crates/editor/src/split.rs b/crates/editor/src/split.rs index e449b79c64c2a94b7e4cf332ff9bd99e0460a0e3..a0d7251d6bbfdf1886fbddfa04a4771f1536aed8 100644 --- a/crates/editor/src/split.rs +++ b/crates/editor/src/split.rs @@ -3356,6 +3356,82 @@ mod tests { ); } + #[gpui::test] + async fn test_added_file_at_end(cx: &mut gpui::TestAppContext) { + use rope::Point; + use unindent::Unindent as _; + + let (editor, mut cx) = init_test(cx).await; + + let base_text = ""; + let current_text = " + aaaa bbbb cccc dddd eeee ffff + bbb + ccc + " + .unindent(); + + let (buffer, diff) = buffer_with_diff(base_text, ¤t_text, &mut cx); + + editor.update(cx, |editor, cx| { + let path = PathKey::for_buffer(&buffer, cx); + editor.set_excerpts_for_path( + path, + buffer.clone(), + vec![Point::new(0, 0)..buffer.read(cx).max_point()], + 0, + diff.clone(), + cx, + ); + }); + + cx.run_until_parked(); + + assert_split_content( + &editor, + " + § + § ----- + aaaa bbbb cccc dddd eeee ffff + bbb + ccc" + .unindent(), + " + § + § ----- + § spacer + § spacer + § spacer" + .unindent(), + &mut cx, + ); + + assert_split_content_with_widths( + &editor, + px(200.0), + px(200.0), + " + § + § ----- + aaaa bbbb\x20 + cccc dddd\x20 + eeee ffff + bbb + ccc" + .unindent(), + " + § + § ----- + § spacer + § spacer + § spacer + § spacer + § spacer" + .unindent(), + &mut cx, + ); + } + #[gpui::test] async fn test_adding_line_to_addition_hunk(cx: &mut gpui::TestAppContext) { use rope::Point;