]> granicus.if.org Git - vim/commitdiff
patch 8.2.1988: still in Insert mode when opening terminal popup v8.2.1988
authorBram Moolenaar <Bram@vim.org>
Sat, 14 Nov 2020 20:34:59 +0000 (21:34 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 14 Nov 2020 20:34:59 +0000 (21:34 +0100)
Problem:    Still in Insert mode when opening terminal popup with a <Cmd>
            mapping in Insert mode.
Solution:   Exit Insert mode. (closes #7295)

src/edit.c
src/testdir/test_terminal.vim
src/version.c

index d92a9513981c0ae0f37e4baf67b532ac7587dd74..8c5cec3a76b046569f7d02be42a1c181bd06dc0c 100644 (file)
@@ -1033,6 +1033,11 @@ doESCkey:
 
        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.
index 8d68ceb5b4377e4384140f00f88a5bb02bf7b9d3..7d6bdbcf6cea63a6d81a9ead8f60d286888963b7 100644 (file)
@@ -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)))
index b031e631aa1bbc31b864a5434e58923a4e44b141..502a876da48590bec73b511898e70a262a4fc842 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1988,
 /**/
     1987,
 /**/