vim: Fix relative line motion

Before this change up and down were in display co-ordinates, after this
change they are in fold coordinates (which matches the vim behaviour).

To make this work without causing usabliity problems, a bunch of extra
keyboard shortcuts now work:

- vim: `z {o,c}` to open,close a fold
- vim: `z f` to fold current visual selection
- vim: `g {j,k,up,down}` to move up/down a display line
- vim: `g {0,^,$,home,end}` to get to start/end of a display line

Fixes: zed-industries/community#1562
This commit is contained in:
Conrad Irwin 2023-08-24 22:11:51 -06:00
parent 0280d5d010
commit 20aa2a4c54
13 changed files with 580 additions and 67 deletions

View file

@ -15,7 +15,10 @@ pub fn substitute(vim: &mut Vim, count: Option<usize>, cx: &mut WindowContext) {
}
if line_mode {
Motion::CurrentLine.expand_selection(map, selection, None, false);
if let Some((point, _)) = Motion::FirstNonWhitespace.move_point(
if let Some((point, _)) = (Motion::FirstNonWhitespace {
display_lines: false,
})
.move_point(
map,
selection.start,
selection.goal,