editor: Fix move line up panic when selection is at end of line next to fold marker (#34982)
Closes #34826 In move line up method, make use of `prev_line_boundary` which accounts for fold map, etc., for selection start row so that we don't incorrectly calculate row range to move up. Release Notes: - Fixed an issue where `editor: move line up` action sometimes crashed if the cursor was at the end of a line beside a fold marker.
This commit is contained in:
parent
7e9d6cc25c
commit
b63d820be2
2 changed files with 36 additions and 1 deletions
|
@ -5069,6 +5069,33 @@ fn test_move_line_up_down(cx: &mut TestAppContext) {
|
|||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_line_up_selection_at_end_of_fold(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple("\n\n\n\n\n\naaaa\nbbbb\ncccc", cx);
|
||||
build_editor(buffer, window, cx)
|
||||
});
|
||||
_ = editor.update(cx, |editor, window, cx| {
|
||||
editor.fold_creases(
|
||||
vec![Crease::simple(
|
||||
Point::new(6, 4)..Point::new(7, 4),
|
||||
FoldPlaceholder::test(),
|
||||
)],
|
||||
true,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([Point::new(7, 4)..Point::new(7, 4)])
|
||||
});
|
||||
assert_eq!(editor.display_text(cx), "\n\n\n\n\n\naaaa⋯\ncccc");
|
||||
editor.move_line_up(&MoveLineUp, window, cx);
|
||||
let buffer_text = editor.buffer.read(cx).snapshot(cx).text();
|
||||
assert_eq!(buffer_text, "\n\n\n\n\naaaa\nbbbb\n\ncccc");
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_line_up_down_with_blocks(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue