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
|
@ -22258,7 +22258,7 @@ fn consume_contiguous_rows(
|
|||
selections: &mut Peekable<std::slice::Iter<Selection<Point>>>,
|
||||
) -> (MultiBufferRow, MultiBufferRow) {
|
||||
contiguous_row_selections.push(selection.clone());
|
||||
let start_row = MultiBufferRow(selection.start.row);
|
||||
let start_row = starting_row(selection, display_map);
|
||||
let mut end_row = ending_row(selection, display_map);
|
||||
|
||||
while let Some(next_selection) = selections.peek() {
|
||||
|
@ -22272,6 +22272,14 @@ fn consume_contiguous_rows(
|
|||
(start_row, end_row)
|
||||
}
|
||||
|
||||
fn starting_row(selection: &Selection<Point>, display_map: &DisplaySnapshot) -> MultiBufferRow {
|
||||
if selection.start.column > 0 {
|
||||
MultiBufferRow(display_map.prev_line_boundary(selection.start).0.row)
|
||||
} else {
|
||||
MultiBufferRow(selection.start.row)
|
||||
}
|
||||
}
|
||||
|
||||
fn ending_row(next_selection: &Selection<Point>, display_map: &DisplaySnapshot) -> MultiBufferRow {
|
||||
if next_selection.end.column > 0 || next_selection.is_empty() {
|
||||
MultiBufferRow(display_map.next_line_boundary(next_selection.end).0.row + 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue