Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

git: Fix incorrect spacers for added or deleted files at the end of the multibuffer (#47525)

Cole Miller9e2c415abb11
diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs
index f5abdfa2197..a7cd0c88e8c 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 e449b79c64c..a0d7251d6bb 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, &current_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,
+ "
+ § <no file>
+ § -----
+ aaaa bbbb cccc dddd eeee ffff
+ bbb
+ ccc"
+ .unindent(),
+ "
+ § <no file>
+ § -----
+ § spacer
+ § spacer
+ § spacer"
+ .unindent(),
+ &mut cx,
+ );
+
+ assert_split_content_with_widths(
+ &editor,
+ px(200.0),
+ px(200.0),
+ "
+ § <no file>
+ § -----
+ aaaa bbbb\x20
+ cccc dddd\x20
+ eeee ffff
+ bbb
+ ccc"
+ .unindent(),
+ "
+ § <no file>
+ § -----
+ § 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;