diff options
-rw-r--r-- | editors/vi.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/editors/vi.c b/editors/vi.c index d37357edd..d20481fbd 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -1128,11 +1128,16 @@ static int get_motion_char(void) int c, cnt; c = get_one_char(); - if (c != '0' && isdigit(c)) { - // get any non-zero motion count - for (cnt = 0; isdigit(c); c = get_one_char()) - cnt = cnt * 10 + (c - '0'); - cmdcnt = (cmdcnt ?: 1) * cnt; + if (isdigit(c)) { + if (c != '0') { + // get any non-zero motion count + for (cnt = 0; isdigit(c); c = get_one_char()) + cnt = cnt * 10 + (c - '0'); + cmdcnt = (cmdcnt ?: 1) * cnt; + } else { + // ensure standalone '0' works + cmdcnt = 0; + } } return c; |