# HG changeset patch # User Bram Moolenaar # Date 1644606003 -3600 # Node ID 1bdb36828dcc4165afb30ace95963f16cbc91b2c # Parent 72da8327a05e0b26286714daf022a624d56af1e7 patch 8.2.4346: a custom statusline may cause Esc to work like Enter Commit: https://github.com/vim/vim/commit/481acb11413a436653e235d2098990b2ad47d195 Author: Bram Moolenaar Date: Fri Feb 11 18:51:45 2022 +0000 patch 8.2.4346: a custom statusline may cause Esc to work like Enter Problem: A custom statusline may cause Esc to work like Enter on the command line when the popup menu is displayed. Solution: Save and restore KeyTyped. (closes #9749) diff --git a/src/drawscreen.c b/src/drawscreen.c --- a/src/drawscreen.c +++ b/src/drawscreen.c @@ -571,6 +571,7 @@ redraw_custom_statusline(win_T *wp) { static int entered = FALSE; int saved_did_emsg = did_emsg; + int saved_KeyTyped = KeyTyped; // When called recursively return. This can happen when the statusline // contains an expression that triggers a redraw. @@ -591,6 +592,9 @@ redraw_custom_statusline(win_T *wp) } did_emsg |= saved_did_emsg; entered = FALSE; + + // A user function may reset KeyTyped, restore it. + KeyTyped = saved_KeyTyped; } #endif diff --git a/src/testdir/dumps/Test_wildmenu_pum_39.dump b/src/testdir/dumps/Test_wildmenu_pum_39.dump new file mode 100644 --- /dev/null +++ b/src/testdir/dumps/Test_wildmenu_pum_39.dump @@ -0,0 +1,10 @@ +> +0&#ffffff0@74 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|s+3#0000000&|t|a|t|u|s| @68 +| +0&&@74 diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -1983,6 +1983,14 @@ func Test_wildmenu_pum() return repeat(['aaaa'], 120) endfunc command -nargs=* -complete=customlist,CmdCompl Tcmd + + func MyStatusLine() abort + return 'status' + endfunc + func SetupStatusline() + set statusline=%!MyStatusLine() + set laststatus=2 + endfunc [CODE] call writefile(commands, 'Xtest') @@ -2166,6 +2174,13 @@ func Test_wildmenu_pum() call term_sendkeys(buf, ":ls\") call term_sendkeys(buf, ":com\ ") call VerifyScreenDump(buf, 'Test_wildmenu_pum_38', {}) + call term_sendkeys(buf, "\\") + + " Esc still works to abort the command when 'statusline' is set + call term_sendkeys(buf, ":call SetupStatusline()\") + call term_sendkeys(buf, ":si\") + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_39', {}) call term_sendkeys(buf, "\\") call StopVimInTerminal(buf) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4346, +/**/ 4345, /**/ 4344,