[vim/vim] silently uses different count when above 999999999 (Issue #20728)

4 views
Skip to first unread message

rokke

unread,
Jul 6, 2026, 9:31:58 PM (4 hours ago) Jul 6
to vim/vim, Subscribed
rokke-git created an issue (vim/vim#20728)

Steps to reproduce

if you use a repetition count above 999999999, it silently changes your repetition count to 999999999.

for example, if you are in normal mode in a buffer with just a 0, and type 1234567890^A, you get 999999999 instead of 1234567890, despite showcmd still showing 1234567890:

  1. ./vim -u <(echo set showcmd) -<<<0
  2. 1234567890^A
  3. now you have 999999999

before ^A:

image.png (view on web)

after ^A:

image.png (view on web)

Expected behaviour

it looks like this is caused because showcmd and count deal with big things differently.

for showcmd, it just shows the 10 most recent characters:
https://github.com/vim/vim/blob/master/src/normal.c#L1772-L1777

and count just caps at 999999999L (9 nines):
https://github.com/vim/vim/blob/master/src/normal.c#L246

since these limits are so close to each other, I think it would make sense to change the count cap to 9999999999L (10 nines), and then set both cap->count0 and ‎showcmd_buf‎ to exactly 9999999999 if the count cap is exceeded. or if the max is from power of two reasons you could set both to 2147483647 or 4294967295. this would properly tell the user that their count has magically changed.

Version of Vim

VIM - Vi IMproved 9.2 (2026 Feb 14, compiled Jul 6 2026) Included patches: 1-782

Environment

n/a

Logs and stack traces

n/a


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20728@github.com>

rokke

unread,
Jul 6, 2026, 10:56:27 PM (2 hours ago) Jul 6
to vim/vim, Subscribed
rokke-git left a comment (vim/vim#20728)

this diff appears to fix the error, but idk what all styles you want. kinda just moved some random declarations earlier so that I could use that one function:

diff --git a/src/normal.c b/src/normal.c
index b803b88f6..e1ec5ddd0 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -214,6 +214,16 @@ check_text_or_curbuf_locked(oparg_T *oap)
     return TRUE;
 }

+/*
+ * Routines for displaying a partly typed command
+ */
+
+static char_u  old_showcmd_buf[SHOWCMD_BUFLEN];  // For push_showcmd()
+static int     showcmd_is_clear = TRUE;
+static int     showcmd_visual = FALSE;
+
+static void display_showcmd(void);
+
 /*
  * Handle the count before a normal command and set cap->count0.
  */
@@ -241,9 +251,11 @@ getcount:
                cap->count0 /= 10;
                del_from_showcmd(4);    // delete the digit and ~@%
            }
-           else if (cap->count0 > 99999999L)
+           else if (cap->count0 > 999999999L)
            {
-               cap->count0 = 999999999L;
+               cap->count0 = 9999999999L;
+               mch_memmove(showcmd_buf, "9999999999", 10);
+               display_showcmd();
            }
            else
            {
@@ -1600,15 +1612,6 @@ may_clear_cmdline(void)
        clear_showcmd();
 }

-/*
- * Routines for displaying a partly typed command
- */
-
-static char_u  old_showcmd_buf[SHOWCMD_BUFLEN];  // For push_showcmd()
-static int     showcmd_is_clear = TRUE;
-static int     showcmd_visual = FALSE;
-
-static void display_showcmd(void);
-
     void
 clear_showcmd(void)


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20728/4899666908@github.com>

Reply all
Reply to author
Forward
0 new messages