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.

Clear counts when switching modes

Conrad Irwin76d55244a1c2
diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs
index 9aa9fffc0a7..70a0b7c7a64 100644
--- a/crates/vim/src/test.rs
+++ b/crates/vim/src/test.rs
@@ -574,3 +574,22 @@ async fn test_folds(cx: &mut gpui::TestAppContext) {
"})
.await;
}
+
+#[gpui::test]
+async fn test_clear_counts(cx: &mut gpui::TestAppContext) {
+ let mut cx = NeovimBackedTestContext::new(cx).await;
+
+ cx.set_shared_state(indoc! {"
+ The quick brown
+ fox juˇmps over
+ the lazy dog"})
+ .await;
+
+ cx.simulate_shared_keystrokes(["4", "escape", "3", "d", "l"])
+ .await;
+ cx.set_shared_state(indoc! {"
+ The quick brown
+ fox juˇ over
+ the lazy dog"})
+ .await;
+}
diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs
index fea6f26ef18..c6488fe171c 100644
--- a/crates/vim/src/vim.rs
+++ b/crates/vim/src/vim.rs
@@ -308,6 +308,9 @@ impl Vim {
state.mode = mode;
state.operator_stack.clear();
});
+ if mode != Mode::Insert {
+ self.take_count();
+ }
cx.emit_global(VimEvent::ModeChanged { mode });
@@ -412,6 +415,7 @@ impl Vim {
popped_operator
}
fn clear_operator(&mut self, cx: &mut WindowContext) {
+ self.take_count();
self.update_state(|state| state.operator_stack.clear());
self.sync_vim_settings(cx);
}
diff --git a/crates/vim/test_data/test_clear_counts.json b/crates/vim/test_data/test_clear_counts.json
new file mode 100644
index 00000000000..8bc78de7d36
--- /dev/null
+++ b/crates/vim/test_data/test_clear_counts.json
@@ -0,0 +1,7 @@
+{"Put":{"state":"The quick brown\nfox juˇmps over\nthe lazy dog"}}
+{"Key":"4"}
+{"Key":"escape"}
+{"Key":"3"}
+{"Key":"d"}
+{"Key":"l"}
+{"Put":{"state":"The quick brown\nfox juˇ over\nthe lazy dog"}}