Commit: patch 9.2.0923: tabpage: closing a tab page loses the alternate tab page
Christian Brabandt <[email protected]> Fri, 7 Aug 2026 22:15:06 +0200
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <[email protected]> |
patch 9.2.0923: tabpage: closing a tab page loses the alternate tab page Commit: https://github.com/vim/vim/commit/a05bd64c1dcde65006997efe0ff5ae6b8a9aa382 Author: Hirohito Higashi <[email protected]> Date: Fri Aug 7 20:09:30 2026 +0000 patch 9.2.0923: tabpage: closing a tab page loses the alternate tab page Problem: Closing the current tab page resets the alternate tab page, even when that is another tab page which still exists, so that CTRL-Tab stops working (igorlfs). Solution: Restore the last used tab page after entering another one to close the current one (Hirohito Higashi). related: #20965 closes: #20973 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Hirohito Higashi <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim index 05c566967..e3749cf04 100644 --- a/src/testdir/test_tabpage.vim +++ b/src/testdir/test_tabpage.vim @@ -942,6 +942,23 @@ func Test_lastused_tabpage() tabonly! endfunc +" Closing a tab page must keep the last used tab page when it is another one. +func Test_lastused_tabpage_close() + tabonly! + tabnew + tabnew + tabfirst + tablast + call assert_equal(1, tabpagenr('#')) + + tabclose + call assert_equal(1, tabpagenr('#')) + call feedkeys("g\<Tab>", "xt") + call assert_equal(1, tabpagenr()) + + tabonly! +endfunc + " Test for tabpage allocation failure func Test_tabpage_alloc_failure() call test_alloc_fail(GetAllocId('newtabpage_tvars'), 0, 0) diff --git a/src/version.c b/src/version.c index 5f5600db7..d1a1f6689 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 923, /**/ 922, /**/ diff --git a/src/window.c b/src/window.c index 8ac5b8f5e..4d4cfab44 100644 --- a/src/window.c +++ b/src/window.c @@ -2665,6 +2665,7 @@ close_last_window_tabpage( return FALSE; buf_T *old_curbuf = curbuf; + tabpage_T *save_lastused = lastused_tabpage; /* * Closing the last window in a tab page. First go to another tab @@ -2682,6 +2683,11 @@ close_last_window_tabpage( // to the other tab page. if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win) win_close_othertab(win, free_buf, prev_curtab); + + // Entering the other tab page made the closed one the last used tab page. + // Restore the previous one when it is still there. + if (valid_tabpage(save_lastused) && save_lastused != curtab) + lastused_tabpage = save_lastused; #ifdef FEAT_JOB_CHANNEL entering_window(curwin); #endif -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wsQyA-000hwl-Jz%40256bit.org.