diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-10-18 13:11:21 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-18 13:11:21 +0100 |
commit | 208567e9d744ef7b89bed1f62e951ae4ee2f6f5f (patch) | |
tree | d92b5868fa996d7bff5daf99052a2c7b401ce148 | |
parent | 9652249a2d02318a28a63a7b5711f25652e8f969 (diff) | |
download | vim-git-208567e9d744ef7b89bed1f62e951ae4ee2f6f5f.tar.gz |
patch 9.0.0786: user command does not get number from :tab modifierv9.0.0786
Problem: User command does not get number from :tab modifier.
Solution: Include the number. (closes #11393, closes #6801)
-rw-r--r-- | src/testdir/test_usercommands.vim | 13 | ||||
-rw-r--r-- | src/usercmd.c | 19 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 33 insertions, 1 deletions
diff --git a/src/testdir/test_usercommands.vim b/src/testdir/test_usercommands.vim index 961aeb2df..f8cc1f53a 100644 --- a/src/testdir/test_usercommands.vim +++ b/src/testdir/test_usercommands.vim @@ -81,6 +81,19 @@ function Test_cmdmods() call assert_equal('silent!', g:mods) tab MyCmd call assert_equal('tab', g:mods) + 0tab MyCmd + call assert_equal('0tab', g:mods) + tab split + tab MyCmd + call assert_equal('tab', g:mods) + 1tab MyCmd + call assert_equal('1tab', g:mods) + tabprev + tab MyCmd + call assert_equal('tab', g:mods) + 2tab MyCmd + call assert_equal('2tab', g:mods) + 2tabclose topleft MyCmd call assert_equal('topleft', g:mods) to MyCmd diff --git a/src/usercmd.c b/src/usercmd.c index 6b3eadc93..0160ac1de 100644 --- a/src/usercmd.c +++ b/src/usercmd.c @@ -1436,7 +1436,24 @@ add_win_cmd_modifers(char_u *buf, cmdmod_T *cmod, int *multi_mods) // :tab if (cmod->cmod_tab > 0) - result += add_cmd_modifier(buf, "tab", multi_mods); + { + int tabnr = cmod->cmod_tab - 1; + + if (tabnr == tabpage_index(curtab)) + { + // For compatibility, don't add a tabpage number if it is the same + // as the default number for :tab. + result += add_cmd_modifier(buf, "tab", multi_mods); + } + else + { + char tab_buf[NUMBUFLEN + 3]; + + sprintf(tab_buf, "%dtab", tabnr); + result += add_cmd_modifier(buf, tab_buf, multi_mods); + } + } + // :topleft if (cmod->cmod_split & WSP_TOP) result += add_cmd_modifier(buf, "topleft", multi_mods); diff --git a/src/version.c b/src/version.c index f3a7e293a..c39a83522 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 786, +/**/ 785, /**/ 784, |