This commit is contained in:
Conrad Irwin 2023-08-25 11:34:07 -06:00
parent f798be6e27
commit 1f3e009b32
2 changed files with 33 additions and 9 deletions

View File

@ -126,10 +126,15 @@ pub fn visual_block_motion(
let map = &s.display_map(); let map = &s.display_map();
let mut head = s.newest_anchor().head().to_display_point(map); let mut head = s.newest_anchor().head().to_display_point(map);
let mut tail = s.oldest_anchor().tail().to_display_point(map); let mut tail = s.oldest_anchor().tail().to_display_point(map);
let mut goal = s.newest_anchor().goal;
let (start, end) = match s.newest_anchor().goal {
SelectionGoal::ColumnRange { start, end } if preserve_goal => (start, end),
SelectionGoal::Column(start) if preserve_goal => (start, start + 1),
_ => (tail.column(), head.column()),
};
let goal = SelectionGoal::ColumnRange { start, end };
let was_reversed = tail.column() > head.column(); let was_reversed = tail.column() > head.column();
if !was_reversed && !preserve_goal { if !was_reversed && !preserve_goal {
head = movement::saturating_left(map, head); head = movement::saturating_left(map, head);
} }
@ -149,13 +154,6 @@ pub fn visual_block_motion(
head = movement::saturating_right(map, head) head = movement::saturating_right(map, head)
} }
let (start, end) = match goal {
SelectionGoal::ColumnRange { start, end } if preserve_goal => (start, end),
SelectionGoal::Column(start) if preserve_goal => (start, start + 1),
_ => (tail.column(), head.column()),
};
goal = SelectionGoal::ColumnRange { start, end };
let columns = if is_reversed { let columns = if is_reversed {
head.column()..tail.column() head.column()..tail.column()
} else if head.column() == tail.column() { } else if head.column() == tail.column() {
@ -791,6 +789,26 @@ mod test {
" "
}) })
.await; .await;
//https://github.com/zed-industries/community/issues/1950
cx.set_shared_state(indoc! {
"Theˇ quick brown
fox jumps over
the lazy dog
"
})
.await;
cx.simulate_shared_keystrokes(["l", "ctrl-v", "j", "j"])
.await;
cx.assert_shared_state(indoc! {
"The «qˇ»uick brown
fox «»umps over
the lazy dog
"
})
.await;
} }
#[gpui::test] #[gpui::test]

View File

@ -30,3 +30,9 @@
{"Key":"o"} {"Key":"o"}
{"Key":"escape"} {"Key":"escape"}
{"Get":{"state":"Theˇouick\nbroo\nfoxo\njumo over the\n\nlazy dog\n","mode":"Normal"}} {"Get":{"state":"Theˇouick\nbroo\nfoxo\njumo over the\n\nlazy dog\n","mode":"Normal"}}
{"Put":{"state":"Theˇ quick brown\n\nfox jumps over\nthe lazy dog\n"}}
{"Key":"l"}
{"Key":"ctrl-v"}
{"Key":"j"}
{"Key":"j"}
{"Get":{"state":"The «qˇ»uick brown\n\nfox «jˇ»umps over\nthe lazy dog\n","mode":"VisualBlock"}}