diff options
Diffstat (limited to 'src/window.c')
-rw-r--r-- | src/window.c | 28 |
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. */ |