vim-patch:9.1.0205: Cannot use modifiers before :-Ntabmove (#28031)

Problem:  Cannot use modifiers before :-Ntabmove.
Solution: Check backwards from the command instead of checking from the
          start of the command line. Slightly adjust docs to make them
          more consistent (zeertzjq).

closes: vim/vim#14289

076faac537
This commit is contained in:
zeertzjq 2024-03-26 05:04:57 +08:00 committed by GitHub
parent 31c4cb2347
commit fb4e2dbbeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 15 deletions

View File

@ -187,7 +187,7 @@ gt *i_CTRL-<PageDown>* *i_<C-PageDown>*
:1tabnext " go to the first tab page :1tabnext " go to the first tab page
:$tabnext " go to the last tab page :$tabnext " go to the last tab page
:tabnext $ " as above :tabnext $ " as above
:tabnext # " go to the last accessed tab page :tabnext # " go to the last accessed tab page
:tabnext - " go to the previous tab page :tabnext - " go to the previous tab page
:tabnext -1 " as above :tabnext -1 " as above
:tabnext + " go to the next tab page :tabnext + " go to the next tab page
@ -239,18 +239,17 @@ REORDERING TAB PAGES:
Move the current tab page to after tab page N. Use zero to Move the current tab page to after tab page N. Use zero to
make the current tab page the first one. N is counted before make the current tab page the first one. N is counted before
the move, thus if the second tab is the current one, the move, thus if the second tab is the current one,
`:tabmove 1` and `:tabmove 2` have no effect. `:tabmove 1` and `:tabmove 2` have no effect.
Without N the tab page is made the last one. > Without N the tab page is made the last one. >
:.tabmove " do nothing :.tabmove " do nothing
:-tabmove " move the tab page to the left :-tabmove " move the tab page to the left
:+tabmove " move the tab page to the right :+tabmove " move the tab page to the right
:0tabmove " move the tab page to the beginning of the tab :0tabmove " move the tab page to the first
" list
:tabmove 0 " as above :tabmove 0 " as above
:tabmove " move the tab page to the last :tabmove " move the tab page to the last
:$tabmove " as above :$tabmove " as above
:tabmove $ " as above :tabmove $ " as above
:tabmove # " move the tab page after the last accessed :tabmove # " move the tab page after the last accessed
" tab page " tab page
:tabm[ove] +[N] :tabm[ove] +[N]

View File

@ -4368,12 +4368,15 @@ static int get_tabpage_arg(exarg_T *eap)
tab_number = 0; tab_number = 0;
} else { } else {
tab_number = (int)eap->line2; tab_number = (int)eap->line2;
char *cmdp = eap->cmd; if (!unaccept_arg0) {
while (--cmdp > *eap->cmdlinep && (*cmdp == ' ' || ascii_isdigit(*cmdp))) {} char *cmdp = eap->cmd;
if (!unaccept_arg0 && *cmdp == '-') { while (--cmdp > *eap->cmdlinep
tab_number--; && (ascii_iswhite(*cmdp) || ascii_isdigit(*cmdp))) {}
if (tab_number < unaccept_arg0) { if (*cmdp == '-') {
eap->errmsg = _(e_invrange); tab_number--;
if (tab_number < unaccept_arg0) {
eap->errmsg = _(e_invrange);
}
} }
} }
} }

View File

@ -117,10 +117,16 @@ function Test_tabpage()
call assert_equal(3, tabpagenr()) call assert_equal(3, tabpagenr())
+3tabmove +3tabmove
call assert_equal(6, tabpagenr()) call assert_equal(6, tabpagenr())
silent -tabmove
call assert_equal(5, tabpagenr())
silent -2 tabmove
call assert_equal(3, tabpagenr())
silent -2 tabmove
call assert_equal(1, tabpagenr())
" The following are a no-op
norm! 2gt norm! 2gt
call assert_equal(2, tabpagenr()) call assert_equal(2, tabpagenr())
" The following are a no-op
tabmove 2 tabmove 2
call assert_equal(2, tabpagenr()) call assert_equal(2, tabpagenr())
2tabmove 2tabmove