diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 4f1453a815..ca157ba697 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -268,6 +268,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) StlClickRecord *tabtab; win_T *ewp; int p_crb_save; + bool save_KeyTyped = KeyTyped; bool is_stl_global = global_stl_height() > 0; ScreenGrid *grid = &default_grid; @@ -422,6 +423,9 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) theend: entered = false; + + // A user function may reset KeyTyped, restore it. + KeyTyped = save_KeyTyped; } void win_redr_winbar(win_T *wp) @@ -639,7 +643,6 @@ int fillchar_status(int *attr, win_T *wp) void redraw_custom_statusline(win_T *wp) { static bool entered = false; - bool saved_KeyTyped = KeyTyped; // When called recursively return. This can happen when the statusline // contains an expression that triggers a redraw. @@ -650,9 +653,6 @@ void redraw_custom_statusline(win_T *wp) win_redr_custom(wp, false, false); entered = false; - - // A user function may reset KeyTyped, restore it. - KeyTyped = saved_KeyTyped; } static void ui_ext_tabline_update(void) diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 68560d5d49..8fc6e9847d 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -2312,6 +2312,15 @@ func Test_wildmenu_pum() set statusline=%!MyStatusLine() set laststatus=2 endfunc + + func MyTabLine() + return 'my tab line' + endfunc + func SetupTabline() + set statusline= + set tabline=%!MyTabLine() + set showtabline=2 + endfunc [CODE] call writefile(commands, 'Xtest') @@ -2503,6 +2512,12 @@ func Test_wildmenu_pum() call term_sendkeys(buf, "\") call VerifyScreenDump(buf, 'Test_wildmenu_pum_39', {}) + " Esc still works to abort the command when 'tabline' is set + call term_sendkeys(buf, ":call SetupTabline()\") + call term_sendkeys(buf, ":si\") + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_40', {}) + call term_sendkeys(buf, "\\") call StopVimInTerminal(buf) call delete('Xtest')