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:
parent
0280d5d010
commit
20aa2a4c54
13 changed files with 580 additions and 67 deletions
|
@ -51,8 +51,15 @@ pub fn init(cx: &mut AppContext) {
|
|||
pub fn visual_motion(motion: Motion, times: Option<usize>, cx: &mut WindowContext) {
|
||||
Vim::update(cx, |vim, cx| {
|
||||
vim.update_active_editor(cx, |editor, cx| {
|
||||
if vim.state().mode == Mode::VisualBlock && !matches!(motion, Motion::EndOfLine) {
|
||||
let is_up_or_down = matches!(motion, Motion::Up | Motion::Down);
|
||||
if vim.state().mode == Mode::VisualBlock
|
||||
&& !matches!(
|
||||
motion,
|
||||
Motion::EndOfLine {
|
||||
display_lines: false
|
||||
}
|
||||
)
|
||||
{
|
||||
let is_up_or_down = matches!(motion, Motion::Up { .. } | Motion::Down { .. });
|
||||
visual_block_motion(is_up_or_down, editor, cx, |map, point, goal| {
|
||||
motion.move_point(map, point, goal, times)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue