]> granicus.if.org Git - vim/commitdiff
patch 8.2.4738: Esc on commandline executes command instead of abandoning it v8.2.4738
authorBram Moolenaar <Bram@vim.org>
Mon, 11 Apr 2022 18:38:56 +0000 (19:38 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 11 Apr 2022 18:38:56 +0000 (19:38 +0100)
Problem:    Esc on commandline executes command instead of abandoning it.
Solution:   Save and restore KeyTyped when removing the popup menu.
            (closes #10154)

src/cmdexpand.c
src/testdir/dumps/Test_wildmenu_with_pum_foldexpr_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_wildmenu_with_pum_foldexpr_2.dump [new file with mode: 0644]
src/testdir/test_cmdline.vim
src/version.c

index 9bcea7e8d61de2a445443f3f5cd76b5dccd7ad1c..87953375d58feb4be52319ca20d61eb51f1423e7 100644 (file)
@@ -378,6 +378,7 @@ int cmdline_pum_active(void)
 void cmdline_pum_remove(void)
 {
     int save_p_lz = p_lz;
+    int        save_KeyTyped = KeyTyped;
 
     pum_undisplay();
     VIM_CLEAR(compl_match_array);
@@ -385,6 +386,10 @@ void cmdline_pum_remove(void)
     update_screen(0);
     p_lz = save_p_lz;
     redrawcmd();
+
+    // When a function is called (e.g. for 'foldtext') KeyTyped might be reset
+    // as a side effect.
+    KeyTyped = save_KeyTyped;
 }
 
 void cmdline_pum_cleanup(cmdline_info_T *cclp)
diff --git a/src/testdir/dumps/Test_wildmenu_with_pum_foldexpr_1.dump b/src/testdir/dumps/Test_wildmenu_with_pum_foldexpr_1.dump
new file mode 100644 (file)
index 0000000..ad57067
--- /dev/null
@@ -0,0 +1,10 @@
+|f+0#0000e05#a8a8a8255|o@1|-@71
+|s+0#0000000#ffffff0|o|m|e| |m|o|r|e| |t|e|x|t| @60
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000001#e0e0e08|s|e|t| @11| +0#4040ff13#ffffff0@58
+| +0#0000001#ffd7ff255|s|e|t|f|i|l|e|t|y|p|e| @3| +0#4040ff13#ffffff0@58
+| +0#0000001#ffd7ff255|s|e|t|g|l|o|b|a|l| @5| +0#4040ff13#ffffff0@58
+| +0#0000001#ffd7ff255|s|e|t|l|o|c|a|l| @6| +0#4040ff13#ffffff0@58
+|:+0#0000000&|s|e|t> @70
diff --git a/src/testdir/dumps/Test_wildmenu_with_pum_foldexpr_2.dump b/src/testdir/dumps/Test_wildmenu_with_pum_foldexpr_2.dump
new file mode 100644 (file)
index 0000000..93270a5
--- /dev/null
@@ -0,0 +1,10 @@
+>f+0#0000e05#a8a8a8255|o@1|-@71
+|s+0#0000000#ffffff0|o|m|e| |m|o|r|e| |t|e|x|t| @60
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
index 8034bdb3e0a03c9df8340b87e80aee2356d2c1ef..8baa1ac6f5b6d4860a2564f875276522836f999a 100644 (file)
@@ -2510,6 +2510,29 @@ func Test_wildmenumode_with_pum()
   cunmap <F2>
 endfunc
 
+func Test_wildmenu_with_pum_foldexpr()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      call setline(1, ['folded one', 'folded two', 'some more text'])
+      func MyFoldText()
+        return 'foo'
+      endfunc
+      set foldtext=MyFoldText() wildoptions=pum
+      normal ggzfj
+  END
+  call writefile(lines, 'Xpumfold')
+  let buf = RunVimInTerminal('-S Xpumfold', #{rows: 10})
+  call term_sendkeys(buf, ":set\<Tab>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_with_pum_foldexpr_1', {})
+
+  call term_sendkeys(buf, "\<Esc>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_with_pum_foldexpr_2', {})
+
+  call StopVimInTerminal(buf)
+  call delete('Xpumfold')
+endfunc
+
 " Test for opening the cmdline completion popup menu from the terminal window.
 " The popup menu should be positioned correctly over the status line of the
 " bottom-most window.
index f1199839d84995d850ff300ede35367924db3cda..27de4e52fb3a0f40750bafd4dc2d9f6931dac00a 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4738,
 /**/
     4737,
 /**/