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)
This commit is contained in:
Bram Moolenaar
2022-02-11 18:51:45 +00:00
parent f6246f51e3
commit 481acb1141
4 changed files with 31 additions and 0 deletions

View File

@ -571,6 +571,7 @@ redraw_custom_statusline(win_T *wp)
{ {
static int entered = FALSE; static int entered = FALSE;
int saved_did_emsg = did_emsg; int saved_did_emsg = did_emsg;
int saved_KeyTyped = KeyTyped;
// When called recursively return. This can happen when the statusline // When called recursively return. This can happen when the statusline
// contains an expression that triggers a redraw. // contains an expression that triggers a redraw.
@ -591,6 +592,9 @@ redraw_custom_statusline(win_T *wp)
} }
did_emsg |= saved_did_emsg; did_emsg |= saved_did_emsg;
entered = FALSE; entered = FALSE;
// A user function may reset KeyTyped, restore it.
KeyTyped = saved_KeyTyped;
} }
#endif #endif

View File

@ -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

View File

@ -1983,6 +1983,14 @@ func Test_wildmenu_pum()
return repeat(['aaaa'], 120) return repeat(['aaaa'], 120)
endfunc endfunc
command -nargs=* -complete=customlist,CmdCompl Tcmd command -nargs=* -complete=customlist,CmdCompl Tcmd
func MyStatusLine() abort
return 'status'
endfunc
func SetupStatusline()
set statusline=%!MyStatusLine()
set laststatus=2
endfunc
[CODE] [CODE]
call writefile(commands, 'Xtest') call writefile(commands, 'Xtest')
@ -2166,6 +2174,13 @@ func Test_wildmenu_pum()
call term_sendkeys(buf, ":ls\<CR>") call term_sendkeys(buf, ":ls\<CR>")
call term_sendkeys(buf, ":com\<Tab> ") call term_sendkeys(buf, ":com\<Tab> ")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_38', {}) call VerifyScreenDump(buf, 'Test_wildmenu_pum_38', {})
call term_sendkeys(buf, "\<C-U>\<CR>")
" Esc still works to abort the command when 'statusline' is set
call term_sendkeys(buf, ":call SetupStatusline()\<CR>")
call term_sendkeys(buf, ":si\<Tab>")
call term_sendkeys(buf, "\<Esc>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_39', {})
call term_sendkeys(buf, "\<C-U>\<CR>") call term_sendkeys(buf, "\<C-U>\<CR>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)

View File

@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4346,
/**/ /**/
4345, 4345,
/**/ /**/