mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
vim: Support count with [x and ]x (#22176)
Fixes: #21577 Fixes: #17245 Release Notes: - vim: Add <count> support for [x/]x
This commit is contained in:
parent
a0a095c6a3
commit
2ecbd97fe8
2 changed files with 22 additions and 2 deletions
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue