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",
|
"ctrl-pageup": "pane::ActivatePrevItem",
|
||||||
"insert": "vim::InsertBefore",
|
"insert": "vim::InsertBefore",
|
||||||
// tree-sitter related commands
|
// tree-sitter related commands
|
||||||
"[ x": "editor::SelectLargerSyntaxNode",
|
"[ x": "vim::SelectLargerSyntaxNode",
|
||||||
"] x": "editor::SelectSmallerSyntaxNode",
|
"] x": "vim::SelectSmallerSyntaxNode",
|
||||||
"] d": "editor::GoToDiagnostic",
|
"] d": "editor::GoToDiagnostic",
|
||||||
"[ d": "editor::GoToPrevDiagnostic",
|
"[ d": "editor::GoToPrevDiagnostic",
|
||||||
"] c": "editor::GoToHunk",
|
"] c": "editor::GoToHunk",
|
||||||
|
|
|
@ -36,6 +36,8 @@ actions!(
|
||||||
SelectPrevious,
|
SelectPrevious,
|
||||||
SelectNextMatch,
|
SelectNextMatch,
|
||||||
SelectPreviousMatch,
|
SelectPreviousMatch,
|
||||||
|
SelectSmallerSyntaxNode,
|
||||||
|
SelectLargerSyntaxNode,
|
||||||
RestoreVisualSelection,
|
RestoreVisualSelection,
|
||||||
VisualInsertEndOfLine,
|
VisualInsertEndOfLine,
|
||||||
VisualInsertFirstNonWhiteSpace,
|
VisualInsertFirstNonWhiteSpace,
|
||||||
|
@ -74,6 +76,24 @@ pub fn register(editor: &mut Editor, cx: &mut ViewContext<Vim>) {
|
||||||
vim.select_match(Direction::Prev, cx);
|
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| {
|
Vim::action(editor, cx, |vim, _: &RestoreVisualSelection, cx| {
|
||||||
let Some((stored_mode, reversed)) = vim.stored_visual_mode.take() else {
|
let Some((stored_mode, reversed)) = vim.stored_visual_mode.take() else {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue