fix vim repeat (#8513)

Release Notes:

- vim: Fixed `.` when multiple windows are open
([#7446](https://github.com/zed-industries/zed/issues/7446)).
- vim: Fixed switching to normal mode after `J`, `<` or `>` in visual
mode ([#4439](https://github.com/zed-industries/zed/issues/4439))
- vim: Added `ctrl-t` and `ctrl-d` for indent/outdent in insert mode.

- Fixed indent/outdent/join lines appearing to work in read-only buffers
([#8423](https://github.com/zed-industries/zed/issues/8423))
- Fixed indent with an empty selection when the cursor was in column 0
This commit is contained in:
Conrad Irwin 2024-02-27 21:36:12 -07:00 committed by GitHub
parent 9a7a267203
commit 9906b31691
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 82 additions and 48 deletions

View file

@ -51,6 +51,8 @@ actions!(
ConvertToUpperCase,
ConvertToLowerCase,
JoinLines,
Indent,
Outdent,
]
);
@ -125,7 +127,34 @@ pub(crate) fn register(workspace: &mut Workspace, cx: &mut ViewContext<Workspace
editor.join_lines(&Default::default(), cx)
}
})
})
});
if vim.state().mode.is_visual() {
vim.switch_mode(Mode::Normal, false, cx)
}
});
});
workspace.register_action(|_: &mut Workspace, _: &Indent, cx| {
Vim::update(cx, |vim, cx| {
vim.record_current_action(cx);
vim.update_active_editor(cx, |_, editor, cx| {
editor.transact(cx, |editor, cx| editor.indent(&Default::default(), cx))
});
if vim.state().mode.is_visual() {
vim.switch_mode(Mode::Normal, false, cx)
}
});
});
workspace.register_action(|_: &mut Workspace, _: &Outdent, cx| {
Vim::update(cx, |vim, cx| {
vim.record_current_action(cx);
vim.update_active_editor(cx, |_, editor, cx| {
editor.transact(cx, |editor, cx| editor.outdent(&Default::default(), cx))
});
if vim.state().mode.is_visual() {
vim.switch_mode(Mode::Normal, false, cx)
}
});
});