tabpage: disallow go-to-previous in cmdline-win #11692

After cbc8d72fde when editing
the command in the command editing window (q:, q/, q?) it was possible
to switch to the previous tab.  Doing so put Nvim in a bad state.
Moreover, switching tabs via the other available mechanisms (gt, gT,
<C-W>gt, <C-W>gT) is not possible when in the command editing window.

Here, the behavior is prevented.  It is no longer possible to switch to
the previous tab when editing the command in the command editing window.
The solution is to share code between gt, gT, and g<Tab>.  Specifically,
goto_tabpage_lastused now calls through goto_tabpage rather than
directly calling goto_tabpage_tp.  Doing so works well because all the
validation enjoyed by gt and gT is present in goto_tabpage.
This commit is contained in:
butwerenotthereyet
2020-01-09 07:31:16 -08:00
committed by Justin M. Keyes
parent 25afa10f92
commit 29b1a4761a
2 changed files with 59 additions and 22 deletions

View File

@@ -4113,8 +4113,9 @@ void goto_tabpage_tp(tabpage_T *tp, int trigger_enter_autocmds, int trigger_leav
// Go to the last accessed tab page, if there is one.
void goto_tabpage_lastused(void)
{
if (valid_tabpage(lastused_tabpage)) {
goto_tabpage_tp(lastused_tabpage, true, true);
int index = tabpage_index(lastused_tabpage);
if (index < tabpage_index(NULL)) {
goto_tabpage(index);
}
}