From 8fba428bc6f36ae038a9286517e15b33257a1359 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 12 May 2022 16:43:20 +0200 Subject: fix(cmd): make :-tabmove work with modifiers (#18447) `:tabmove` takes either an argument (`:tabmove -`) or an address (`:-tabmove`). The code assumed that `:tabmove` is the first command on the cmdline, but that is not the case when using additional modifiers like `:silent`. Make the addr parsing more robust by searching the command first, then going back to check for a potential address `-`. --- src/nvim/ex_docmd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 91b8628c33..34f306bdfd 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5248,7 +5248,9 @@ static int get_tabpage_arg(exarg_T *eap) tab_number = 0; } else { tab_number = (int)eap->line2; - if (!unaccept_arg0 && *skipwhite(*eap->cmdlinep) == '-') { + char *cmdp = eap->cmd; + while (--cmdp > *eap->cmdlinep && (*cmdp == ' ' || ascii_isdigit(*cmdp))) {} + if (!unaccept_arg0 && *cmdp == '-') { tab_number--; if (tab_number < unaccept_arg0) { eap->errmsg = e_invarg; -- cgit