]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.591 v7.3.591
authorBram Moolenaar <Bram@vim.org>
Fri, 6 Jul 2012 16:27:39 +0000 (18:27 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 6 Jul 2012 16:27:39 +0000 (18:27 +0200)
Problem:    Can only move to a tab by absolute number.
Solution:   Move a number of tabs to the left or the right. (Lech Lorens)

runtime/doc/tabpage.txt
src/ex_cmds.h
src/ex_docmd.c
src/testdir/test62.in
src/testdir/test62.ok
src/version.c
src/window.c

index a30d3a179773a41e6173a9e417ab8520349175c4..a2da5b30732e6365b67e0c84b03e38ac8fe9d3c6 100644 (file)
@@ -173,10 +173,20 @@ Other commands:
 REORDERING TAB PAGES:
 
 :tabm[ove] [N]                                         *:tabm* *:tabmove*
+:[N]tabm[ove]
                Move the current tab page to after tab page N.  Use zero to
                make the current tab page the first one.  Without N the tab
                page is made the last one.
 
+:tabm[ove] +[N]
+:tabm[ove] -[N]
+               Move the current tab page N places to the right (with +) or to
+               the left (with -).
+
+Note that although it is possible to move a tab behind the N-th one by using
+:Ntabmove, it is impossible to move it by N places by using :+Ntabmove. For
+clarification what +N means in this context see |[range]|.
+
 
 LOOPING OVER TAB PAGES:
 
index ac61f1a0ab9e9fd6f2371286716b21529ec6fbc7..cfe150225a0602c04820cf037031dbeb2ad129ec 100644 (file)
@@ -944,7 +944,7 @@ EX(CMD_tabfind,             "tabfind",      ex_splitview,
 EX(CMD_tabfirst,       "tabfirst",     ex_tabnext,
                        TRLBAR),
 EX(CMD_tabmove,                "tabmove",      ex_tabmove,
-                       RANGE|NOTADR|ZEROR|COUNT|TRLBAR|ZEROR),
+                       RANGE|NOTADR|ZEROR|EXTRA|NOSPC|TRLBAR),
 EX(CMD_tablast,                "tablast",      ex_tabnext,
                        TRLBAR),
 EX(CMD_tabnext,                "tabnext",      ex_tabnext,
index 6740a51da43b004000d9909898a26fb8f7d1db9f..cc80c14b78faefb006ccbee8b476e4a2fa3f6275 100644 (file)
@@ -7478,7 +7478,42 @@ ex_tabnext(eap)
 ex_tabmove(eap)
     exarg_T    *eap;
 {
-    tabpage_move(eap->addr_count == 0 ? 9999 : (int)eap->line2);
+    int tab_number = 9999;
+
+    if (eap->arg && *eap->arg != NUL)
+    {
+       char_u *p = eap->arg;
+       int    relative = 0; /* argument +N/-N means: move N places to the
+                             * right/left relative to the current position. */
+
+       if (*eap->arg == '-')
+       {
+           relative = -1;
+           p = eap->arg + 1;
+       }
+       else if (*eap->arg == '+')
+       {
+           relative = 1;
+           p = eap->arg + 1;
+       }
+       else
+           p = eap->arg;
+
+       if (p == skipdigits(p))
+       {
+           /* No numbers as argument. */
+           eap->errmsg = e_invarg;
+           return;
+       }
+
+       tab_number = getdigits(&p);
+       if (relative != 0)
+           tab_number = tab_number * relative + tabpage_index(curtab) - 1;;
+    }
+    else if (eap->addr_count != 0)
+       tab_number = eap->line2;
+
+    tabpage_move(tab_number);
 }
 
 /*
index 1e514cd21a6b6903ad9fa52670946027b4c34e7a..fd1844bdc3a5bfd4059f54659b4ae1b62a666e08 100644 (file)
@@ -93,6 +93,34 @@ STARTTEST
 :endif
 :"
 :"
+:for i in range(9) | tabnew | endfor
+1gt
+Go\12=tabpagenr()\r\r\e
+:tabmove 5
+i\12=tabpagenr()\r\r\e
+:tabmove -2
+i\12=tabpagenr()\r\r\e
+:tabmove +4
+i\12=tabpagenr()\r\r\e
+:tabmove
+i\12=tabpagenr()\r\r\e
+:tabmove -20
+i\12=tabpagenr()\r\r\e
+:tabmove +20
+i\12=tabpagenr()\r\r\e
+:3tabmove
+i\12=tabpagenr()\r\r\e
+:7tabmove 5
+i\12=tabpagenr()\r\r\e
+:let a='No error caught.'
+:try
+:tabmove foo
+:catch E474
+:let a='E474 caught.'
+:endtry
+i\12=a\r\e
+:"
+:"
 :/^Results/,$w! test.out
 :qa!
 ENDTEST
index 7625cd2e2c5cc88e44cce2e74fc1a1322695681e..0ac1fcbbd4c90099b15b41345e578846a7bbd48e 100644 (file)
@@ -8,3 +8,13 @@ settabvar: pass
 tab drop 1: pass
 tab drop 2: pass
 tab drop 3: pass
+1
+6
+4
+8
+10
+1
+10
+4
+6
+E474 caught.
index 637abb7df3f5b68928bec4f92b008088b5bd90e9..4bfec7865a68465d5ecb66fc2527d0bc9d1ed673 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    591,
 /**/
     590,
 /**/
index c65f49d790e300aff192d8b3d6ef9f8ef3b060b4..6460684bc38d5dec6930585d2822694205541d23 100644 (file)
@@ -3929,7 +3929,7 @@ tabpage_move(nr)
     }
 
     /* Re-insert it at the specified position. */
-    if (n == 0)
+    if (n <= 0)
     {
        curtab->tp_next = first_tabpage;
        first_tabpage = curtab;