Fix single column vim selections

This commit is contained in:
Conrad Irwin 2023-10-20 11:17:19 -06:00
parent b596b4153f
commit 1c36134cf9
6 changed files with 38 additions and 6 deletions

View file

@ -255,8 +255,18 @@ mod test {
4
5"})
.await;
cx.simulate_shared_keystrokes(["shift-g", "ctrl-v", "g", "g", "g", "ctrl-x"])
cx.simulate_shared_keystrokes(["shift-g", "ctrl-v", "g", "g"])
.await;
cx.assert_shared_state(indoc! {"
«1ˇ»
«2ˇ»
«3ˇ» 2
«4ˇ»
«5ˇ»"})
.await;
cx.simulate_shared_keystrokes(["g", "ctrl-x"]).await;
cx.assert_shared_state(indoc! {"
ˇ0
0

View file

@ -169,10 +169,10 @@ pub fn visual_block_motion(
let is_reversed = tail_x > head_x;
if was_reversed && !is_reversed {
tail = movement::left(map, tail);
tail = movement::saturating_left(map, tail);
tail_x = map.x_for_point(tail, &text_layout_details);
} else if !was_reversed && is_reversed {
tail = movement::right(map, tail);
tail = movement::saturating_right(map, tail);
tail_x = map.x_for_point(tail, &text_layout_details);
}
if !is_reversed && !preserve_goal {
@ -180,8 +180,12 @@ pub fn visual_block_motion(
head_x = map.x_for_point(head, &text_layout_details);
}
dbg!(head, head_x, tail, tail_x);
let positions = if is_reversed {
head_x..tail_x
} else if head_x == tail_x {
map.x_for_point(movement::saturating_left(map, tail), &text_layout_details)..head_x
} else {
tail_x..head_x
};

View file

@ -9,6 +9,7 @@
{"Key":"ctrl-v"}
{"Key":"g"}
{"Key":"g"}
{"Get":{"state":"«1ˇ»\n«2ˇ»\n«3ˇ» 2\n«4ˇ»\n«5ˇ»","mode":"VisualBlock"}}
{"Key":"g"}
{"Key":"ctrl-x"}
{"Get":{"state":"ˇ0\n0\n0 2\n0\n0","mode":"Normal"}}