Skip to content

Commit

Permalink
patch 8.2.1988: still in Insert mode when opening terminal popup
Browse files Browse the repository at this point in the history
Problem:    Still in Insert mode when opening terminal popup with a <Cmd>
            mapping in Insert mode.
Solution:   Exit Insert mode. (closes #7295)
  • Loading branch information
brammool committed Nov 14, 2020
1 parent 6453cc8 commit e41decc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,11 @@ edit(

case K_COMMAND: // <Cmd>command<CR>
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.
Expand Down
18 changes: 18 additions & 0 deletions src/testdir/test_terminal.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,24 @@ func Test_terminal_popup_with_cmd()
unlet s:winid
endfunc

func Test_terminal_popup_insert_cmd()
CheckUnix

inoremap <F3> <Cmd>call StartTermInPopup()<CR>
func StartTermInPopup()
call term_start(['/bin/sh', '-c', 'cat'], #{hidden: v:true})->popup_create(#{highlight: 'Pmenu'})
endfunc
call feedkeys("i\<F3>")
sleep 10m
call assert_equal('n', mode())

call feedkeys("\<C-D>", 'xt')
sleep 20m
call feedkeys(":q\<CR>", 'xt')
delfunc StartTermInPopup
iunmap <F3>
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)))
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1988,
/**/
1987,
/**/
Expand Down

0 comments on commit e41decc

Please sign in to comment.