From e41decc892a115335259096c3bc0204dd99b372b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Nov 2020 21:34:59 +0100 Subject: patch 8.2.1988: still in Insert mode when opening terminal popup Problem: Still in Insert mode when opening terminal popup with a mapping in Insert mode. Solution: Exit Insert mode. (closes #7295) --- src/edit.c | 5 +++++ src/testdir/test_terminal.vim | 18 ++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 25 insertions(+) (limited to 'src') diff --git a/src/edit.c b/src/edit.c index d92a95139..8c5cec3a7 100644 --- a/src/edit.c +++ b/src/edit.c @@ -1033,6 +1033,11 @@ doESCkey: case K_COMMAND: // command do_cmdline(NULL, getcmdkeycmd, NULL, 0); +#ifdef FEAT_TERMINAL + if (term_use_loop()) + // Started a terminal that gets the input, exit Insert mode. + goto doESCkey; +#endif break; case K_CURSORHOLD: // Didn't type something for a while. diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 8d68ceb5b..7d6bdbcf6 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -1237,6 +1237,24 @@ func Test_terminal_popup_with_cmd() unlet s:winid endfunc +func Test_terminal_popup_insert_cmd() + CheckUnix + + inoremap call StartTermInPopup() + func StartTermInPopup() + call term_start(['/bin/sh', '-c', 'cat'], #{hidden: v:true})->popup_create(#{highlight: 'Pmenu'}) + endfunc + call feedkeys("i\") + sleep 10m + call assert_equal('n', mode()) + + call feedkeys("\", 'xt') + sleep 20m + call feedkeys(":q\", 'xt') + delfunc StartTermInPopup + iunmap +endfunc + func Check_dump01(off) call assert_equal('one two three four five', trim(getline(a:off + 1))) call assert_equal('~ Select Word', trim(getline(a:off + 7))) diff --git a/src/version.c b/src/version.c index b031e631a..502a876da 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1988, /**/ 1987, /**/ -- cgit v1.2.1