diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 1875f44f78..88a4855cf0 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -528,7 +528,7 @@ } }, { - "context": "vim_operator == a || vim_operator == i || vim_operator == cs", + "context": "vim_operator == a || vim_operator == i || vim_operator == cs || vim_operator == helix_next || vim_operator == helix_previous", "bindings": { "w": "vim::Word", "shift-w": ["vim::Word", { "ignore_punctuation": true }], diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index e2c022dce1..2f3f40da22 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -498,14 +498,16 @@ impl Vim { Some(Operator::HelixMatch) => { self.select_current_object(object, around, window, cx) } - Some(Operator::SelectNext) => self.select_next_object(object, around, window, cx), - Some(Operator::SelectPrevious) => { - self.select_previous_object(object, around, window, cx) - } _ => { // Can't do anything for namespace operators. Ignoring } }, + Some(Operator::HelixNext { around }) => { + self.select_next_object(object, around, window, cx); + } + Some(Operator::HelixPrevious { around }) => { + self.select_previous_object(object, around, window, cx); + } Some(Operator::DeleteSurrounds) => { waiting_operator = Some(Operator::DeleteSurrounds); } diff --git a/crates/vim/src/state.rs b/crates/vim/src/state.rs index fc5234ff80..556113e20a 100644 --- a/crates/vim/src/state.rs +++ b/crates/vim/src/state.rs @@ -133,8 +133,12 @@ pub enum Operator { ReplaceWithRegister, Exchange, HelixMatch, - SelectNext, - SelectPrevious, + HelixNext { + around: bool, + }, + HelixPrevious { + around: bool, + }, } #[derive(Default, Clone, Debug)] @@ -1028,8 +1032,8 @@ impl Operator { Operator::ReplayRegister => "@", Operator::ToggleComments => "gc", Operator::HelixMatch => "helix_m", - Operator::SelectNext { .. } => "helix_]", - Operator::SelectPrevious { .. } => "helix_[", + Operator::HelixNext { .. } => "helix_next", + Operator::HelixPrevious { .. } => "helix_previous", } } @@ -1044,8 +1048,8 @@ impl Operator { Operator::AutoIndent => "=".to_string(), Operator::ShellCommand => "=".to_string(), Operator::HelixMatch => "m".to_string(), - Operator::SelectNext => "]".to_string(), - Operator::SelectPrevious => "[".to_string(), + Operator::HelixNext { .. } => "]".to_string(), + Operator::HelixPrevious { .. } => "[".to_string(), _ => self.id().to_string(), } } @@ -1086,8 +1090,8 @@ impl Operator { | Operator::OppositeCase | Operator::ToggleComments | Operator::HelixMatch - | Operator::SelectNext { .. } - | Operator::SelectPrevious { .. } => false, + | Operator::HelixNext { .. } + | Operator::HelixPrevious { .. } => false, } } @@ -1112,8 +1116,8 @@ impl Operator { | Operator::ChangeSurrounds { target: None } | Operator::DeleteSurrounds | Operator::Exchange - | Operator::SelectNext { .. } - | Operator::SelectPrevious { .. } => true, + | Operator::HelixNext { .. } + | Operator::HelixPrevious { .. } => true, Operator::Yank | Operator::Object { .. } | Operator::FindForward { .. } diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 525d291389..a8164b5b96 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -785,19 +785,17 @@ impl Vim { vim.push_operator(Operator::HelixMatch, window, cx) }); Vim::action(editor, cx, |vim, action: &PushHelixNext, window, cx| { - vim.push_operator(Operator::SelectNext, window, cx); vim.push_operator( - Operator::Object { + Operator::HelixNext { around: action.around, }, window, cx, - ) + ); }); Vim::action(editor, cx, |vim, action: &PushHelixPrevious, window, cx| { - vim.push_operator(Operator::SelectPrevious, window, cx); vim.push_operator( - Operator::Object { + Operator::HelixPrevious { around: action.around, }, window,