From 85c3aec6e74f09dfb6530ba706e1ab92e6e2d9f5 Mon Sep 17 00:00:00 2001 From: Brian Tan Date: Fri, 13 Dec 2024 21:06:18 -0500 Subject: [PATCH] vim: Maintain block cursor for navigating/non-modifying operators (#21502) The cursor shape now only changes to underline for operators that modify text (like: delete, change, yank) while maintaining block shape for navigation operators (like: find, till). This better matches Vim/Nvim's behavior where the cursor only changes shape when an operator that will modify text is pending. Release Notes: - vim: Improved cursor shape behavior to better match Vim --- crates/vim/src/vim.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 43dbdc6316..9fca9f139e 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -626,10 +626,23 @@ impl Vim { pub fn cursor_shape(&self) -> CursorShape { match self.mode { Mode::Normal => { - if self.operator_stack.is_empty() { - CursorShape::Block + if let Some(operator) = self.operator_stack.last() { + match operator { + // Navigation operators -> Block cursor + Operator::FindForward { .. } + | Operator::FindBackward { .. } + | Operator::Mark + | Operator::Jump { .. } + | Operator::Register + | Operator::RecordRegister + | Operator::ReplayRegister => CursorShape::Block, + + // All other operators -> Underline cursor + _ => CursorShape::Underline, + } } else { - CursorShape::Underline + // No operator active -> Block cursor + CursorShape::Block } } Mode::Replace => CursorShape::Underline,