Skip to content

Commit 45ea2a4

Browse files
committed
updated for version 7.3.591
Problem: Can only move to a tab by absolute number. Solution: Move a number of tabs to the left or the right. (Lech Lorens)
1 parent 25357e0 commit 45ea2a4

File tree

7 files changed

+88
-3
lines changed

7 files changed

+88
-3
lines changed

runtime/doc/tabpage.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,20 @@ Other commands:
173173
REORDERING TAB PAGES:
174174

175175
:tabm[ove] [N] *:tabm* *:tabmove*
176+
:[N]tabm[ove]
176177
Move the current tab page to after tab page N. Use zero to
177178
make the current tab page the first one. Without N the tab
178179
page is made the last one.
179180

181+
:tabm[ove] +[N]
182+
:tabm[ove] -[N]
183+
Move the current tab page N places to the right (with +) or to
184+
the left (with -).
185+
186+
Note that although it is possible to move a tab behind the N-th one by using
187+
:Ntabmove, it is impossible to move it by N places by using :+Ntabmove. For
188+
clarification what +N means in this context see |[range]|.
189+
180190

181191
LOOPING OVER TAB PAGES:
182192

src/ex_cmds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ EX(CMD_tabfind, "tabfind", ex_splitview,
944944
EX(CMD_tabfirst, "tabfirst", ex_tabnext,
945945
TRLBAR),
946946
EX(CMD_tabmove, "tabmove", ex_tabmove,
947-
RANGE|NOTADR|ZEROR|COUNT|TRLBAR|ZEROR),
947+
RANGE|NOTADR|ZEROR|EXTRA|NOSPC|TRLBAR),
948948
EX(CMD_tablast, "tablast", ex_tabnext,
949949
TRLBAR),
950950
EX(CMD_tabnext, "tabnext", ex_tabnext,

src/ex_docmd.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7478,7 +7478,42 @@ ex_tabnext(eap)
74787478
ex_tabmove(eap)
74797479
exarg_T *eap;
74807480
{
7481-
tabpage_move(eap->addr_count == 0 ? 9999 : (int)eap->line2);
7481+
int tab_number = 9999;
7482+
7483+
if (eap->arg && *eap->arg != NUL)
7484+
{
7485+
char_u *p = eap->arg;
7486+
int relative = 0; /* argument +N/-N means: move N places to the
7487+
* right/left relative to the current position. */
7488+
7489+
if (*eap->arg == '-')
7490+
{
7491+
relative = -1;
7492+
p = eap->arg + 1;
7493+
}
7494+
else if (*eap->arg == '+')
7495+
{
7496+
relative = 1;
7497+
p = eap->arg + 1;
7498+
}
7499+
else
7500+
p = eap->arg;
7501+
7502+
if (p == skipdigits(p))
7503+
{
7504+
/* No numbers as argument. */
7505+
eap->errmsg = e_invarg;
7506+
return;
7507+
}
7508+
7509+
tab_number = getdigits(&p);
7510+
if (relative != 0)
7511+
tab_number = tab_number * relative + tabpage_index(curtab) - 1;;
7512+
}
7513+
else if (eap->addr_count != 0)
7514+
tab_number = eap->line2;
7515+
7516+
tabpage_move(tab_number);
74827517
}
74837518

74847519
/*

src/testdir/test62.in

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,34 @@ STARTTEST
9393
:endif
9494
:"
9595
:"
96+
:for i in range(9) | tabnew | endfor
97+
1gt
98+
Go=tabpagenr()
99+
:tabmove 5
100+
i=tabpagenr()
101+
:tabmove -2
102+
i=tabpagenr()
103+
:tabmove +4
104+
i=tabpagenr()
105+
:tabmove
106+
i=tabpagenr()
107+
:tabmove -20
108+
i=tabpagenr()
109+
:tabmove +20
110+
i=tabpagenr()
111+
:3tabmove
112+
i=tabpagenr()
113+
:7tabmove 5
114+
i=tabpagenr()
115+
:let a='No error caught.'
116+
:try
117+
:tabmove foo
118+
:catch E474
119+
:let a='E474 caught.'
120+
:endtry
121+
i=a
122+
:"
123+
:"
96124
:/^Results/,$w! test.out
97125
:qa!
98126
ENDTEST

src/testdir/test62.ok

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ settabvar: pass
88
tab drop 1: pass
99
tab drop 2: pass
1010
tab drop 3: pass
11+
1
12+
6
13+
4
14+
8
15+
10
16+
1
17+
10
18+
4
19+
6
20+
E474 caught.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ static char *(features[]) =
714714

715715
static int included_patches[] =
716716
{ /* Add new patch number below this line */
717+
/**/
718+
591,
717719
/**/
718720
590,
719721
/**/

src/window.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3929,7 +3929,7 @@ tabpage_move(nr)
39293929
}
39303930

39313931
/* Re-insert it at the specified position. */
3932-
if (n == 0)
3932+
if (n <= 0)
39333933
{
39343934
curtab->tp_next = first_tabpage;
39353935
first_tabpage = curtab;

0 commit comments

Comments
 (0)