changeset 19433:af9d5585cfbf v8.2.0274

patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global Commit: https://github.com/vim/vim/commit/9e2bcb5d23138d45a0b6f9c1542b5facc807efe7 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 18 21:33:00 2020 +0100 patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global Problem: Hang with combination of feedkeys(), Ex mode and :global. (Yegappan Lakshmanan) Solution: Add the pending_exmode_active flag.
author Bram Moolenaar <Bram@vim.org>
date Tue, 18 Feb 2020 21:45:04 +0100
parents 686bc965b4b4
children 4f7cdab4da93
files src/ex_docmd.c src/getchar.c src/globals.h src/testdir/test_ex_mode.vim src/version.c
diffstat 5 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -6185,9 +6185,11 @@ do_exedit(
 		hold_gui_events = 0;
 #endif
 		must_redraw = CLEAR;
+		pending_exmode_active = TRUE;
 
 		main_loop(FALSE, TRUE);
 
+		pending_exmode_active = FALSE;
 		RedrawingDisabled = rd;
 		no_wait_return = nwr;
 		msg_scroll = ms;
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -3041,6 +3041,10 @@ vgetorpeek(int advance)
 #ifdef FEAT_CMDWIN
 		    tc = c;
 #endif
+		    // return from main_loop()
+		    if (pending_exmode_active)
+			exmode_active = EXMODE_NORMAL;
+
 		    break;
 		}
 
--- a/src/globals.h
+++ b/src/globals.h
@@ -1028,6 +1028,10 @@ EXTERN int	motion_force INIT(= 0); // mo
  * Ex mode (Q) state
  */
 EXTERN int exmode_active INIT(= 0);	// zero, EXMODE_NORMAL or EXMODE_VIM
+
+// Flag set when main_loop() should exit when entering Ex mode.
+EXTERN int pending_exmode_active INIT(= FALSE);
+
 EXTERN int ex_no_reprint INIT(= FALSE); // no need to print after z or p
 
 EXTERN int reg_recording INIT(= 0);	// register for recording  or zero
--- a/src/testdir/test_ex_mode.vim
+++ b/src/testdir/test_ex_mode.vim
@@ -111,4 +111,12 @@ func Test_open_command()
   close!
 endfunc
 
+func Test_Ex_feedkeys()
+  " this doesn't do anything useful, just check it doesn't hang
+  new
+  call setline(1, ["foo"])
+  call feedkeys("Qg/foo/visual\<CR>", "xt")
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    274,
+/**/
     273,
 /**/
     272,