summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-08-21 19:07:17 +0200
committerBram Moolenaar <Bram@vim.org>2016-08-21 19:07:17 +0200
commit9b7f8ce9eb3cb704f8cc14ab659bf86b1d6dc13c (patch)
treeef3886176e8111bad2543299f5e96f3af2f37e60 /src
parent920694c1b60fac8017b8909efcc24f189804a9bb (diff)
patch 7.4.2237v7.4.2237
Problem: Can't use "." and "$" with ":tab". Solution: Support a range for ":tab". (Hirohito Higashi)
Diffstat (limited to 'src')
-rw-r--r--src/ex_docmd.c19
-rw-r--r--src/testdir/test_tabpage.vim32
-rw-r--r--src/version.c2
3 files changed, 47 insertions, 6 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 1a7fbfabb7..9f1d2279d3 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1858,9 +1858,7 @@ do_one_cmd(
/*
* 2. Handle command modifiers.
*/
- p = ea.cmd;
- if (VIM_ISDIGIT(*ea.cmd))
- p = skipwhite(skipdigits(ea.cmd));
+ p = skip_range(ea.cmd, NULL);
switch (*p)
{
/* When adding an entry, also modify cmd_exists(). */
@@ -1992,10 +1990,19 @@ do_one_cmd(
case 't': if (checkforcmd(&p, "tab", 3))
{
#ifdef FEAT_WINDOWS
- if (vim_isdigit(*ea.cmd))
- cmdmod.tab = atoi((char *)ea.cmd) + 1;
- else
+ long tabnr = get_address(&ea, &ea.cmd, ADDR_TABS,
+ ea.skip, FALSE);
+ if (tabnr == MAXLNUM)
cmdmod.tab = tabpage_index(curtab) + 1;
+ else
+ {
+ if (tabnr < 0 || tabnr > LAST_TAB_NR)
+ {
+ errormsg = (char_u *)_(e_invrange);
+ goto doend;
+ }
+ cmdmod.tab = tabnr + 1;
+ }
ea.cmd = p;
#endif
continue;
diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim
index e6b85d6e14..f1c41e967b 100644
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -186,4 +186,36 @@ function Test_tabpage_with_autocmd()
bw!
endfunction
+function Test_tabpage_with_tab_modifier()
+ for n in range(4)
+ tabedit
+ endfor
+
+ function s:check_tab(pre_nr, cmd, post_nr)
+ exec 'tabnext ' . a:pre_nr
+ exec a:cmd
+ call assert_equal(a:post_nr, tabpagenr())
+ call assert_equal('help', &filetype)
+ helpclose
+ endfunc
+
+ call s:check_tab(1, 'tab help', 2)
+ call s:check_tab(1, '3tab help', 4)
+ call s:check_tab(1, '.tab help', 2)
+ call s:check_tab(1, '.+1tab help', 3)
+ call s:check_tab(1, '0tab help', 1)
+ call s:check_tab(2, '+tab help', 4)
+ call s:check_tab(2, '+2tab help', 5)
+ call s:check_tab(4, '-tab help', 4)
+ call s:check_tab(4, '-2tab help', 3)
+ call s:check_tab(3, '$tab help', 6)
+ call assert_fails('99tab help', 'E16:')
+ call assert_fails('+99tab help', 'E16:')
+ call assert_fails('-99tab help', 'E16:')
+
+ delfunction s:check_tab
+ tabonly!
+ bw!
+endfunction
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 8b8653190d..fe60c32489 100644
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2237,
+/**/
2236,
/**/
2235,