1
0
forked from aniani/vim

patch 8.2.1401: cannot jump to the last used tabpage

Problem:    Cannot jump to the last used tabpage.
Solution:   Add g<Tab> and tabpagnr('#'). (Yegappan Lakshmanan, closes #6661,
            neovim #11626)
This commit is contained in:
Bram Moolenaar
2020-08-09 14:04:42 +02:00
parent 730b248339
commit 62a232506d
10 changed files with 107 additions and 5 deletions

View File

@@ -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.
@@ -4277,6 +4290,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.