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
+13 -2
View File
@@ -851,7 +851,7 @@ fn test_move_cursor_multibyte(cx: &mut TestAppContext) {
let view = cx
.add_window(|cx| {
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcde\nαβγδε\n", cx);
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcde\nαβγδε", cx);
build_editor(buffer.clone(), cx)
})
.root(cx);
@@ -869,7 +869,7 @@ fn test_move_cursor_multibyte(cx: &mut TestAppContext) {
true,
cx,
);
assert_eq!(view.display_text(cx), "ⓐⓑ⋯ⓔ\nab⋯e\nαβ⋯ε\n");
assert_eq!(view.display_text(cx), "ⓐⓑ⋯ⓔ\nab⋯e\nαβ⋯ε");
view.move_right(&MoveRight, cx);
assert_eq!(
@@ -934,6 +934,17 @@ fn test_move_cursor_multibyte(cx: &mut TestAppContext) {
view.selections.display_ranges(cx),
&[empty_range(1, "ab⋯e".len())]
);
view.move_down(&MoveDown, cx);
assert_eq!(
view.selections.display_ranges(cx),
&[empty_range(2, "αβ⋯ε".len())]
);
view.move_up(&MoveUp, cx);
assert_eq!(
view.selections.display_ranges(cx),
&[empty_range(1, "ab⋯e".len())]
);
view.move_up(&MoveUp, cx);
assert_eq!(
view.selections.display_ranges(cx),
+2
View File
@@ -147,7 +147,9 @@ pub fn down_by_rows(
goal_x = map.x_for_point(point, text_layout_details)
}
dbg!(point);
let mut clipped_point = map.clip_point(point, Bias::Right);
dbg!(clipped_point);
if clipped_point.row() > point.row() {
clipped_point = map.clip_point(point, Bias::Left);
}