diff options
author | Grzegorz Milka <grzegorzmilka@gmail.com> | 2016-10-23 00:00:47 +0200 |
---|---|---|
committer | Grzegorz Milka <grzegorzmilka@gmail.com> | 2016-10-23 00:37:13 +0200 |
commit | d7b942b54e4bae5510549ceffb3280e89871cff5 (patch) | |
tree | f25b395b5791e13d69dff7b4d4f66fb0edf66f0f /src | |
parent | 9ca90fdb9fda017962129125ea886fbf07345f62 (diff) | |
download | rneovim-d7b942b54e4bae5510549ceffb3280e89871cff5.tar.gz rneovim-d7b942b54e4bae5510549ceffb3280e89871cff5.tar.bz2 rneovim-d7b942b54e4bae5510549ceffb3280e89871cff5.zip |
vim-patch:7.4.2237
Problem: Can't use "." and "$" with ":tab".
Solution: Support a range for ":tab". (Hirohito Higashi)
https://github.com/vim/vim/commit/9b7f8ce9eb3cb704f8cc14ab659bf86b1d6dc13c
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_docmd.c | 21 | ||||
-rw-r--r-- | src/nvim/testdir/test_tabpage.vim | 32 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
3 files changed, 46 insertions, 9 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 9f83688e1e..cbe4d19d2c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1302,8 +1302,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, * 2. Handle command modifiers. */ p = ea.cmd; - if (ascii_isdigit(*ea.cmd)) - p = skipwhite(skipdigits(ea.cmd)); + p = skip_range(ea.cmd, NULL); switch (*p) { /* When adding an entry, also modify cmd_exists(). */ case 'a': if (!checkforcmd(&ea.cmd, "aboveleft", 3)) @@ -1406,12 +1405,18 @@ static char_u * do_one_cmd(char_u **cmdlinep, continue; case 't': if (checkforcmd(&p, "tab", 3)) { - if (ascii_isdigit(*ea.cmd)) - cmdmod.tab = atoi((char *)ea.cmd) + 1; - else - cmdmod.tab = tabpage_index(curtab) + 1; - ea.cmd = p; - continue; + 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; + continue; } if (!checkforcmd(&ea.cmd, "topleft", 2)) break; diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index e6b85d6e14..f1c41e967b 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/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/nvim/version.c b/src/nvim/version.c index 1a72238394..fffd8e79de 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -204,7 +204,7 @@ static int included_patches[] = { // 2240, // 2239, // 2238 NA - // 2237, + 2237, // 2236, // 2235, // 2234 NA |