summaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-09 14:04:42 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-09 14:04:42 +0200
commit62a232506d06f6d1b3b7271801c907d6294dfe84 (patch)
treed95d049e9676ef5b8a63ca9096401ca52dc8b90d /src/window.c
parent730b24833952f0f4a9a17b7815b0d9f87c609eb8 (diff)
downloadvim-git-62a232506d06f6d1b3b7271801c907d6294dfe84.tar.gz
patch 8.2.1401: cannot jump to the last used tabpagev8.2.1401
Problem: Cannot jump to the last used tabpage. Solution: Add g<Tab> and tabpagnr('#'). (Yegappan Lakshmanan, closes #6661, neovim #11626)
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/window.c b/src/window.c
index 4b2ff4b52..7d8122efd 100644
--- a/src/window.c
+++ b/src/window.c
@@ -627,6 +627,11 @@ wingotofile:
goto_tabpage(-(int)Prenum1);
break;
+ case TAB: // CTRL-W g<Tab>: go to last used tab page
+ if (goto_tabpage_lastused() == FAIL)
+ beep_flush();
+ break;
+
default:
beep_flush();
break;
@@ -3809,6 +3814,9 @@ free_tabpage(tabpage_T *tp)
unref_var_dict(tp->tp_vars);
#endif
+ if (tp == lastused_tabpage)
+ lastused_tabpage = NULL;
+
vim_free(tp->tp_localdir);
vim_free(tp->tp_prevdir);
@@ -3883,6 +3891,8 @@ win_new_tabpage(int after)
newtp->tp_topframe = topframe;
last_status(FALSE);
+ lastused_tabpage = tp;
+
#if defined(FEAT_GUI)
// When 'guioptions' includes 'L' or 'R' may have to remove or add
// scrollbars. Have to update them anyway.
@@ -4118,6 +4128,7 @@ enter_tabpage(
int row;
int old_off = tp->tp_firstwin->w_winrow;
win_T *next_prevwin = tp->tp_prevwin;
+ tabpage_T *last_tab = curtab;
curtab = tp;
firstwin = tp->tp_firstwin;
@@ -4160,6 +4171,8 @@ enter_tabpage(
if (curtab->tp_old_Columns != Columns && starting == 0)
shell_new_columns(); // update window widths
+ lastused_tabpage = last_tab;
+
#if defined(FEAT_GUI)
// When 'guioptions' includes 'L' or 'R' may have to remove or add
// scrollbars. Have to update them anyway.
@@ -4278,6 +4291,21 @@ goto_tabpage_tp(
}
/*
+ * Go to the last accessed tab page, if there is one.
+ * Return OK or FAIL
+ */
+ int
+goto_tabpage_lastused(void)
+{
+ if (valid_tabpage(lastused_tabpage))
+ {
+ goto_tabpage_tp(lastused_tabpage, TRUE, TRUE);
+ return OK;
+ }
+ return FAIL;
+}
+
+/*
* Enter window "wp" in tab page "tp".
* Also updates the GUI tab.
*/