Skip to content

Commit e41decc

Browse files
committed
patch 8.2.1988: still in Insert mode when opening terminal popup
Problem: Still in Insert mode when opening terminal popup with a <Cmd> mapping in Insert mode. Solution: Exit Insert mode. (closes #7295)
1 parent 6453cc8 commit e41decc

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/edit.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,11 @@ edit(
10331033

10341034
case K_COMMAND: // <Cmd>command<CR>
10351035
do_cmdline(NULL, getcmdkeycmd, NULL, 0);
1036+
#ifdef FEAT_TERMINAL
1037+
if (term_use_loop())
1038+
// Started a terminal that gets the input, exit Insert mode.
1039+
goto doESCkey;
1040+
#endif
10361041
break;
10371042

10381043
case K_CURSORHOLD: // Didn't type something for a while.

src/testdir/test_terminal.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,24 @@ func Test_terminal_popup_with_cmd()
12371237
unlet s:winid
12381238
endfunc
12391239

1240+
func Test_terminal_popup_insert_cmd()
1241+
CheckUnix
1242+
1243+
inoremap <F3> <Cmd>call StartTermInPopup()<CR>
1244+
func StartTermInPopup()
1245+
call term_start(['/bin/sh', '-c', 'cat'], #{hidden: v:true})->popup_create(#{highlight: 'Pmenu'})
1246+
endfunc
1247+
call feedkeys("i\<F3>")
1248+
sleep 10m
1249+
call assert_equal('n', mode())
1250+
1251+
call feedkeys("\<C-D>", 'xt')
1252+
sleep 20m
1253+
call feedkeys(":q\<CR>", 'xt')
1254+
delfunc StartTermInPopup
1255+
iunmap <F3>
1256+
endfunc
1257+
12401258
func Check_dump01(off)
12411259
call assert_equal('one two three four five', trim(getline(a:off + 1)))
12421260
call assert_equal('~ Select Word', trim(getline(a:off + 7)))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1988,
753755
/**/
754756
1987,
755757
/**/

0 commit comments

Comments
 (0)