]> granicus.if.org Git - vim/commitdiff
patch 8.2.4672: using :normal with Ex mode may make :substitute hang v8.2.4672
authorBram Moolenaar <Bram@vim.org>
Sun, 3 Apr 2022 11:59:34 +0000 (12:59 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 3 Apr 2022 11:59:34 +0000 (12:59 +0100)
Problem:    Using :normal with Ex mode may make :substitute hang.
Solution:   When getting an empty line behave like 'q' was typed.
            (closes #10070)

src/ex_cmds.c
src/testdir/test_normal.vim
src/version.c

index 25f06e623ca9861065c86215157ac11326a6ea1d..8cdac4b74ea6d424defad51af594008d9999c0b9 100644 (file)
@@ -4233,6 +4233,11 @@ ex_substitute(exarg_T *eap)
                            {
                                typed = *resp;
                                vim_free(resp);
+                               // When ":normal" runs out of characters we get
+                               // an empty line.  Use "q" to get out of the
+                               // loop.
+                               if (ex_normal_busy && typed == NUL)
+                                   typed = 'q';
                            }
                        }
                        else
index cd987ab3d0035ca127db33ff1db6ed1ac73c3ba0..b86a72673cfc621502ac95c80502fb0e6b6e0d09 100644 (file)
@@ -2641,6 +2641,15 @@ func Test_normal33_g_cmd2()
   bw!
 endfunc
 
+func Test_normal_ex_substitute()
+  " This was hanging on the substitute prompt.
+  new
+  call setline(1, 'a')
+  exe "normal! gggQs/a/b/c\<CR>"
+  call assert_equal('a', getline(1))
+  bwipe!
+endfunc
+
 " Test for g CTRL-G
 func Test_g_ctrl_g()
   new
index c6111fc92d6000590c9313b0056dd64be57145ac..3fec52ea08a3276625aa5596dffce1d651f83ae4 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4672,
 /**/
     4671,
 /**/