aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-03 20:38:31 +0800
committerGitHub <noreply@github.com>2022-04-03 20:38:31 +0800
commitd73bf3138a802bb6c1c654cd913d4e91932287f8 (patch)
tree739de02b0003e666042c124451e1a90bc87b399f
parente9e16655af1bacd4b1499fed00a142512c120710 (diff)
downloadrneovim-d73bf3138a802bb6c1c654cd913d4e91932287f8.tar.gz
rneovim-d73bf3138a802bb6c1c654cd913d4e91932287f8.tar.bz2
rneovim-d73bf3138a802bb6c1c654cd913d4e91932287f8.zip
vim-patch:8.2.4672: using :normal with Ex mode may make :substitute hang (#17983)
Problem: Using :normal with Ex mode may make :substitute hang. Solution: When getting an empty line behave like 'q' was typed. (closes vim/vim#10070) https://github.com/vim/vim/commit/ce416b453a849c837f9f6ffc91dd4792d84e1bfd Cherry-pick a comment from patch 8.2.0363.
-rw-r--r--src/nvim/ex_cmds.c6
-rw-r--r--src/nvim/testdir/test_normal.vim10
2 files changed, 16 insertions, 0 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index ff803c3553..b493ad61ae 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3867,6 +3867,12 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
if (resp != NULL) {
typed = *resp;
xfree(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 {
char_u *orig_line = NULL;
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index f45cd96733..1feffe1f8c 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/testdir/test_normal.vim
@@ -1843,6 +1843,16 @@ fun! 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