Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Allow vim counts with undo and redo (#13950)
Matt Fellenz034d905435ea
diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.jsonindex a44c9af4c16..0e98636e416 100644--- a/assets/keymaps/vim.json+++ b/assets/keymaps/vim.json@@ -232,8 +232,8 @@"ctrl-x": "vim::Decrement","p": "vim::Paste","shift-p": ["vim::Paste", { "before": true }],- "u": "editor::Undo",- "ctrl-r": "editor::Redo",+ "u": "vim::Undo",+ "ctrl-r": "vim::Redo","r": ["vim::PushOperator", "Replace"],"s": "vim::Substitute","shift-s": "vim::SubstituteLine",diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rsindex 1daf7ef017d..781c6bb98a9 100644--- a/crates/vim/src/normal.rs+++ b/crates/vim/src/normal.rs@@ -65,6 +65,8 @@ actions!(Indent,Outdent,ToggleComments,+ Undo,+ Redo,]);@@ -180,6 +182,27 @@ pub(crate) fn register(workspace: &mut Workspace, cx: &mut ViewContext<Workspace});});+ workspace.register_action(|_: &mut Workspace, _: &Undo, cx| {+ Vim::update(cx, |vim, cx| {+ let times = vim.take_count(cx);+ vim.update_active_editor(cx, |_, editor, cx| {+ for _ in 0..times.unwrap_or(1) {+ editor.undo(&editor::actions::Undo, cx);+ }+ });+ })+ });+ workspace.register_action(|_: &mut Workspace, _: &Redo, cx| {+ Vim::update(cx, |vim, cx| {+ let times = vim.take_count(cx);+ vim.update_active_editor(cx, |_, editor, cx| {+ for _ in 0..times.unwrap_or(1) {+ editor.redo(&editor::actions::Redo, cx);+ }+ });+ })+ });+paste::register(workspace, cx);repeat::register(workspace, cx);scroll::register(workspace, cx);