]> granicus.if.org Git - vim/commitdiff
patch 9.0.0786: user command does not get number from :tab modifier v9.0.0786
authorzeertzjq <zeertzjq@outlook.com>
Tue, 18 Oct 2022 12:11:21 +0000 (13:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 18 Oct 2022 12:11:21 +0000 (13:11 +0100)
Problem:    User command does not get number from :tab modifier.
Solution:   Include the number. (closes #11393, closes #6801)

src/testdir/test_usercommands.vim
src/usercmd.c
src/version.c

index 961aeb2df7825ba8ec8c0cd9e8dc747ae74b83bf..f8cc1f53a1ca67367561a095d2dc853c39853e13 100644 (file)
@@ -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
index 6b3eadc9340336b1976e896c317379ae9d0f7274..0160ac1de1ca5c8e13b8648c392444e72dbfacaf 100644 (file)
@@ -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);
index f3a7e293afbd1e0ded48db2782b2e9509a754ccc..c39a83522d7acec70b326703f0f2de90cf05a7b5 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    786,
 /**/
     785,
 /**/