From 68223bdb67e8d7b2c78ad59fc82a3e4b832c3895 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 22 Nov 2021 15:53:37 -0700 Subject: [PATCH 1/2] Place the cursor at end of first line when splitting selections into lines --- crates/editor/src/lib.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/crates/editor/src/lib.rs b/crates/editor/src/lib.rs index 158b2823b4..b2bc2ed8fd 100644 --- a/crates/editor/src/lib.rs +++ b/crates/editor/src/lib.rs @@ -1999,16 +1999,7 @@ impl Editor { let mut to_unfold = Vec::new(); let mut new_selections = Vec::new(); for selection in selections.iter() { - if selection.start.row != selection.end.row { - new_selections.push(Selection { - id: post_inc(&mut self.next_selection_id), - start: selection.start, - end: selection.start, - reversed: false, - goal: SelectionGoal::None, - }); - } - for row in selection.start.row + 1..selection.end.row { + for row in selection.start.row..selection.end.row { let cursor = Point::new(row, buffer.line_len(row)); new_selections.push(Selection { id: post_inc(&mut self.next_selection_id), From ce71ed39599333c23d36f209fd9508c3bbf9859f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 22 Nov 2021 16:19:24 -0800 Subject: [PATCH 2/2] Adjust assertion in test for split_selection_into_lines --- crates/editor/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/editor/src/lib.rs b/crates/editor/src/lib.rs index b2bc2ed8fd..d34c680ac8 100644 --- a/crates/editor/src/lib.rs +++ b/crates/editor/src/lib.rs @@ -4447,7 +4447,7 @@ mod tests { assert_eq!( view.selection_ranges(cx), [ - DisplayPoint::new(0, 1)..DisplayPoint::new(0, 1), + DisplayPoint::new(0, 5)..DisplayPoint::new(0, 5), DisplayPoint::new(1, 5)..DisplayPoint::new(1, 5), DisplayPoint::new(2, 5)..DisplayPoint::new(2, 5), DisplayPoint::new(3, 5)..DisplayPoint::new(3, 5),