Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix crash when joining two consecutive lines (#10000)
Hansec6efe262fd7
diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rsindex d9a2ff4d034..48c894e5750 100644--- a/crates/editor/src/editor_tests.rs+++ b/crates/editor/src/editor_tests.rs@@ -2685,6 +2685,65 @@ fn test_join_lines_with_multi_selection(cx: &mut TestAppContext) {});}+#[gpui::test]+async fn test_join_lines_with_git_diff_base(+ executor: BackgroundExecutor,+ cx: &mut gpui::TestAppContext,+) {+ init_test(cx, |_| {});++ let mut cx = EditorTestContext::new(cx).await;++ let diff_base = r#"+ Line 0+ Line 1+ Line 2+ Line 3+ "#+ .unindent();++ cx.set_state(+ &r#"+ ˇLine 0+ Line 1+ Line 2+ Line 3+ "#+ .unindent(),+ );++ cx.set_diff_base(Some(&diff_base));+ executor.run_until_parked();++ // Join lines+ cx.update_editor(|editor, cx| {+ editor.join_lines(&JoinLines, cx);+ });+ executor.run_until_parked();++ cx.assert_editor_state(+ &r#"+ Line 0ˇ Line 1+ Line 2+ Line 3+ "#+ .unindent(),+ );+ // Join again+ cx.update_editor(|editor, cx| {+ editor.join_lines(&JoinLines, cx);+ });+ executor.run_until_parked();++ cx.assert_editor_state(+ &r#"+ Line 0 Line 1ˇ Line 2+ Line 3+ "#+ .unindent(),+ );+}+#[gpui::test]async fn test_manipulate_lines_with_single_selection(cx: &mut TestAppContext) {init_test(cx, |_| {});diff --git a/crates/git/src/diff.rs b/crates/git/src/diff.rsindex 38be750cf0b..a8b14c2a499 100644--- a/crates/git/src/diff.rs+++ b/crates/git/src/diff.rs@@ -130,6 +130,7 @@ impl BufferDiff {if end_point.column > 0 {end_point.row += 1;+ end_point.column = 0;}Some(DiffHunk {