Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
vim: Support count with [x and ]x (#22176)
Conrad Irwin2ecbd97fe854
diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.jsonindex 597388368db..417916db4d6 100644--- a/assets/keymaps/vim.json+++ b/assets/keymaps/vim.json@@ -230,8 +230,8 @@"ctrl-pageup": "pane::ActivatePrevItem","insert": "vim::InsertBefore",// tree-sitter related commands- "[ x": "editor::SelectLargerSyntaxNode",- "] x": "editor::SelectSmallerSyntaxNode",+ "[ x": "vim::SelectLargerSyntaxNode",+ "] x": "vim::SelectSmallerSyntaxNode","] d": "editor::GoToDiagnostic","[ d": "editor::GoToPrevDiagnostic","] c": "editor::GoToHunk",diff --git a/crates/vim/src/visual.rs b/crates/vim/src/visual.rsindex 8d2b31a1de9..b062d07ad99 100644--- a/crates/vim/src/visual.rs+++ b/crates/vim/src/visual.rs@@ -36,6 +36,8 @@ actions!(SelectPrevious,SelectNextMatch,SelectPreviousMatch,+ SelectSmallerSyntaxNode,+ SelectLargerSyntaxNode,RestoreVisualSelection,VisualInsertEndOfLine,VisualInsertFirstNonWhiteSpace,@@ -74,6 +76,24 @@ pub fn register(editor: &mut Editor, cx: &mut ViewContext<Vim>) {vim.select_match(Direction::Prev, cx);});+ Vim::action(editor, cx, |vim, _: &SelectLargerSyntaxNode, cx| {+ let count = Vim::take_count(cx).unwrap_or(1);+ for _ in 0..count {+ vim.update_editor(cx, |_, editor, cx| {+ editor.select_larger_syntax_node(&Default::default(), cx);+ });+ }+ });++ Vim::action(editor, cx, |vim, _: &SelectSmallerSyntaxNode, cx| {+ let count = Vim::take_count(cx).unwrap_or(1);+ for _ in 0..count {+ vim.update_editor(cx, |_, editor, cx| {+ editor.select_smaller_syntax_node(&Default::default(), cx);+ });+ }+ });+Vim::action(editor, cx, |vim, _: &RestoreVisualSelection, cx| {let Some((stored_mode, reversed)) = vim.stored_visual_mode.take() else {return;