Change summary
  crates/vim/src/test.rs                      | 16 +++++++
crates/vim/src/vim.rs                       |  2 
crates/vim/test_data/test_jk_max_count.json | 47 ++++++++++++++++++++++
3 files changed, 65 insertions(+)
  Detailed changes
  
  
    
    @@ -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) {
  
  
  
    
    @@ -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),
             )
         }
  
  
  
    
    @@ -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"}}