Skip to content

Commit

Permalink
updated for version 7.3.591
Browse files Browse the repository at this point in the history
Problem:    Can only move to a tab by absolute number.
Solution:   Move a number of tabs to the left or the right. (Lech Lorens)
  • Loading branch information
brammool committed Jul 6, 2012
1 parent 25357e0 commit 45ea2a4
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 3 deletions.
10 changes: 10 additions & 0 deletions runtime/doc/tabpage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion src/ex_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
37 changes: 36 additions & 1 deletion src/ex_docmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down
28 changes: 28 additions & 0 deletions src/testdir/test62.in
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,34 @@ STARTTEST
:endif
:"
:"
:for i in range(9) | tabnew | endfor
1gt
Go=tabpagenr()
:tabmove 5
i=tabpagenr()
:tabmove -2
i=tabpagenr()
:tabmove +4
i=tabpagenr()
:tabmove
i=tabpagenr()
:tabmove -20
i=tabpagenr()
:tabmove +20
i=tabpagenr()
:3tabmove
i=tabpagenr()
:7tabmove 5
i=tabpagenr()
:let a='No error caught.'
:try
:tabmove foo
:catch E474
:let a='E474 caught.'
:endtry
i=a
:"
:"
:/^Results/,$w! test.out
:qa!
ENDTEST
Expand Down
10 changes: 10 additions & 0 deletions src/testdir/test62.ok
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
591,
/**/
590,
/**/
Expand Down
2 changes: 1 addition & 1 deletion src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 45ea2a4

Please sign in to comment.