Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

vim: Maintain block cursor for navigating/non-modifying operators (#21502)

Brian Tan85c3aec6e74f
diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs
index 43dbdc6316b..9fca9f139eb 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,