Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
vim: Decrease max vim count (#40059)
AidanV762fa9b3c79d
diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rsindex 2f130356a70..297ef644736 100644--- a/crates/vim/src/test.rs+++ b/crates/vim/src/test.rs@@ -13,6 +13,7 @@ use editor::{};use futures::StreamExt;use gpui::{KeyBinding, Modifiers, MouseButton, TestAppContext, px};+use itertools::Itertools;use language::Point;pub use neovim_backed_test_context::*;use settings::SettingsStore;@@ -974,6 +975,21 @@ async fn test_jk_delay(cx: &mut gpui::TestAppContext) {cx.assert_state("jˇkhello", Mode::Normal);}+#[perf]+#[gpui::test]+async fn test_jk_max_count(cx: &mut gpui::TestAppContext) {+ let mut cx = NeovimBackedTestContext::new(cx).await;++ cx.set_shared_state("1\nˇ2\n3").await;+ cx.simulate_shared_keystrokes("9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 j")+ .await;+ cx.shared_state().await.assert_eq("1\n2\nˇ3");++ let number: String = usize::MAX.to_string().split("").join(" ");+ cx.simulate_shared_keystrokes(&format!("{number} k")).await;+ cx.shared_state().await.assert_eq("ˇ1\n2\n3");+}+#[perf]#[gpui::test]async fn test_comma_w(cx: &mut gpui::TestAppContext) {diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rsindex 4999a4b04c2..d4c81737fdb 100644--- a/crates/vim/src/vim.rs+++ b/crates/vim/src/vim.rs@@ -1525,6 +1525,7 @@ impl Vim {post_count.checked_mul(10).and_then(|post_count| post_count.checked_add(number))+ .filter(|post_count| *post_count < isize::MAX as usize).unwrap_or(post_count),)} else {@@ -1534,6 +1535,7 @@ impl Vim {pre_count.checked_mul(10).and_then(|pre_count| pre_count.checked_add(number))+ .filter(|pre_count| *pre_count < isize::MAX as usize).unwrap_or(pre_count),)}diff --git a/crates/vim/test_data/test_jk_max_count.json b/crates/vim/test_data/test_jk_max_count.jsonnew file mode 100644index 00000000000..83eab46a18a--- /dev/null+++ b/crates/vim/test_data/test_jk_max_count.json@@ -0,0 +1,47 @@+{"Put":{"state":"1\nˇ2\n3"}}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"9"}+{"Key":"j"}+{"Get":{"state":"1\n2\nˇ3","mode":"Normal"}}+{"Key":""}+{"Key":"1"}+{"Key":"8"}+{"Key":"4"}+{"Key":"4"}+{"Key":"6"}+{"Key":"7"}+{"Key":"4"}+{"Key":"4"}+{"Key":"0"}+{"Key":"7"}+{"Key":"3"}+{"Key":"7"}+{"Key":"0"}+{"Key":"9"}+{"Key":"5"}+{"Key":"5"}+{"Key":"1"}+{"Key":"6"}+{"Key":"1"}+{"Key":"5"}+{"Key":""}+{"Key":"k"}+{"Get":{"state":"ˇ1\n2\n3","mode":"Normal"}}