Add a unit test showing panic in move_line_down

Max Brunsfeld created

Change summary

crates/editor/src/editor.rs | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

Detailed changes

crates/editor/src/editor.rs πŸ”—

@@ -1826,6 +1826,7 @@ impl Editor {
 
                 let next_row_display_end =
                     DisplayPoint::new(display_rows.end, display_map.line_len(display_rows.end));
+
                 let next_row_buffer_end = display_map.next_row_boundary(next_row_display_end).1;
                 let next_row_buffer_end_offset = next_row_buffer_end.to_offset(&buffer);
 
@@ -5168,6 +5169,27 @@ mod tests {
         });
     }
 
+    #[gpui::test]
+    fn test_move_line_up_down_with_blocks(cx: &mut gpui::MutableAppContext) {
+        let settings = EditorSettings::test(&cx);
+        let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx);
+        let (_, editor) =
+            cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
+        editor.update(cx, |editor, cx| {
+            editor.insert_blocks(
+                [BlockProperties {
+                    position: Point::new(2, 0),
+                    disposition: BlockDisposition::Below,
+                    height: 1,
+                    render: Arc::new(|_| Empty::new().boxed()),
+                }],
+                cx,
+            );
+            editor.select_ranges([Point::new(2, 0)..Point::new(2, 0)], None, cx);
+            editor.move_line_down(&MoveLineDown, cx);
+        });
+    }
+
     #[gpui::test]
     fn test_clipboard(cx: &mut gpui::MutableAppContext) {
         let buffer = MultiBuffer::build_simple("oneβœ… two three four five six ", cx);