vim-patch:8.2.4428: crash when switching tabpage while in the cmdline window

Problem:    Crash when switching tabpage while in the cmdline window.
Solution:   Disallow switching tabpage when in the cmdline window.
0f6e28f686

Ensure cmdline window doesn't stop us from closing tabs with EXITFREE.
mem_free_all -> win_free_all -> tabpage_close -> ... -> goto_tabpage_tp
-> CHECK_CMDWIN can cause an infinite loop if Nvim is exited without using
standard methods such as :qa! and friends (e.g: killed via a signal).
This issue had caused the ASAN CI's functionaltests to timeout.

Cherry-pick Test_cmdwin_tabpage from v8.2.4463.
38b85cb4d7
This bug was already fixed in Nvim. Note that g<Tab> inside cmdwin is already
tested for in tabnewentered_spec.lua anyway.

E492 is thrown after E11 when using ":norm" in assert_fails for some reason
(except after v8.2.1919, which isn't ported yet).
As v8.2.1183 isn't ported yet, so we cannot assert E11 directly.
Modify the test to check for E11 and E492 seperately; when v8.2.1183 is ported,
the assertion for E492 will fail and the changes can be reverted to match
upstream.

Remove redundant CHECK_CMDWIN from goto_tabpage; it's handled with text_locked()
and text_locked_msg() above:

vim-patch:8.2.4434: duplicate check for cmdline window

Problem:    Duplicate check for cmdline window.
Solution:   Remove the second check. (Sean Dewar, closes vim/vim#9816)
16b51d26fe
This commit is contained in:
Sean Dewar
2022-02-21 10:55:36 +00:00
parent 895ca52e4c
commit 880d3537d0
6 changed files with 39 additions and 10 deletions

View File

@@ -73,6 +73,15 @@ typedef enum {
static char *m_onlyone = N_("Already only one window");
/// @return the current window, unless in the cmdline window and "prevwin" is
/// set, then return "prevwin".
win_T *prevwin_curwin(void)
FUNC_ATTR_WARN_UNUSED_RESULT
{
// In cmdwin, the alternative buffer should be used.
return is_in_cmdwin() && prevwin != NULL ? prevwin : curwin;
}
/// all CTRL-W window commands are handled here, called from normal_cmd().
///
/// @param xchar extra char from ":wincmd gx" or NUL
@@ -3857,6 +3866,11 @@ int win_new_tabpage(int after, char_u *filename)
tabpage_T *newtp;
int n;
if (cmdwin_type != 0) {
emsg(_(e_cmdwin));
return FAIL;
}
newtp = alloc_tabpage();
// Remember the current windows in this Tab page.
@@ -4255,6 +4269,8 @@ void goto_tabpage(int n)
/// @param trigger_leave_autocmds when true trigger *Leave autocommands.
void goto_tabpage_tp(tabpage_T *tp, bool trigger_enter_autocmds, bool trigger_leave_autocmds)
{
CHECK_CMDWIN;
// Don't repeat a message in another tab page.
set_keep_msg(NULL, 0);