changeset 28293:aa533dc41223 v8.2.4672

patch 8.2.4672: using :normal with Ex mode may make :substitute hang Commit: https://github.com/vim/vim/commit/ce416b453a849c837f9f6ffc91dd4792d84e1bfd Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 3 12:59:34 2022 +0100 patch 8.2.4672: using :normal with Ex mode may make :substitute hang Problem: Using :normal with Ex mode may make :substitute hang. Solution: When getting an empty line behave like 'q' was typed. (closes #10070)
author Bram Moolenaar <Bram@vim.org>
date Sun, 03 Apr 2022 14:00:03 +0200
parents 5143c731bd61
children 98b3cfbb2d9f
files src/ex_cmds.c src/testdir/test_normal.vim src/version.c
diffstat 3 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -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
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4672,
+/**/
     4671,
 /**/
     4670,