summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ex_docmd.c9
-rw-r--r--src/testdir/test_tabpage.vim35
-rw-r--r--src/version.c2
-rw-r--r--src/window.c3
4 files changed, 43 insertions, 6 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 96eac7fbe..502f33e2a 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -5412,6 +5412,15 @@ get_tabpage_arg(exarg_T *eap)
{
if (STRCMP(p, "$") == 0)
tab_number = LAST_TAB_NR;
+ else if (STRCMP(p, "#") == 0)
+ if (valid_tabpage(lastused_tabpage))
+ tab_number = tabpage_index(lastused_tabpage);
+ else
+ {
+ eap->errmsg = ex_errmsg(e_invargval, eap->arg);
+ tab_number = 0;
+ goto theend;
+ }
else if (p == p_save || *p_save == '-' || *p != NUL
|| tab_number > LAST_TAB_NR)
{
diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim
index 67469718f..e561064eb 100644
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -784,6 +784,7 @@ func Test_lastused_tabpage()
call assert_beeps('call feedkeys("g\<Tab>", "xt")')
call assert_beeps('call feedkeys("\<C-Tab>", "xt")')
call assert_beeps('call feedkeys("\<C-W>g\<Tab>", "xt")')
+ call assert_fails('tabnext #', 'E475:')
" open four tab pages
tabnew
@@ -808,17 +809,41 @@ func Test_lastused_tabpage()
call assert_equal(4, tabpagenr())
call assert_equal(2, tabpagenr('#'))
+ " Test for :tabnext #
+ tabnext #
+ call assert_equal(2, tabpagenr())
+ call assert_equal(4, tabpagenr('#'))
+
" Try to jump to a closed tab page
- tabclose 2
+ tabclose #
call assert_equal(0, tabpagenr('#'))
call feedkeys("g\<Tab>", "xt")
- call assert_equal(3, tabpagenr())
+ call assert_equal(2, tabpagenr())
call feedkeys("\<C-Tab>", "xt")
- call assert_equal(3, tabpagenr())
+ call assert_equal(2, tabpagenr())
call feedkeys("\<C-W>g\<Tab>", "xt")
- call assert_equal(3, tabpagenr())
+ call assert_equal(2, tabpagenr())
+ call assert_fails('tabnext #', 'E475:')
+ call assert_equal(2, tabpagenr())
- tabclose!
+ " Test for :tabonly #
+ let wnum = win_getid()
+ $tabnew
+ tabonly #
+ call assert_equal(wnum, win_getid())
+ call assert_equal(1, tabpagenr('$'))
+
+ " Test for :tabmove #
+ tabnew
+ let wnum = win_getid()
+ tabnew
+ tabnew
+ tabnext 2
+ tabmove #
+ call assert_equal(4, tabpagenr())
+ call assert_equal(wnum, win_getid())
+
+ tabonly!
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 4d86275a8..a08b5d7b0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1413,
+/**/
1412,
/**/
1411,
diff --git a/src/window.c b/src/window.c
index d2e5c5c2a..75e049562 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3844,6 +3844,7 @@ free_tabpage(tabpage_T *tp)
win_new_tabpage(int after)
{
tabpage_T *tp = curtab;
+ tabpage_T *prev_tp = curtab;
tabpage_T *newtp;
int n;
@@ -3893,7 +3894,7 @@ win_new_tabpage(int after)
newtp->tp_topframe = topframe;
last_status(FALSE);
- lastused_tabpage = tp;
+ lastused_tabpage = prev_tp;
#if defined(FEAT_GUI)
// When 'guioptions' includes 'L' or 'R' may have to remove or add