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)
ce416b453a

Cherry-pick a comment from patch 8.2.0363.
This commit is contained in:
zeertzjq
2022-04-03 20:38:31 +08:00
committed by GitHub
parent e9e16655af
commit d73bf3138a
2 changed files with 16 additions and 0 deletions

View File

@@ -3867,6 +3867,12 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
if (resp != NULL) { if (resp != NULL) {
typed = *resp; typed = *resp;
xfree(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 { } else {
char_u *orig_line = NULL; char_u *orig_line = NULL;

View File

@@ -1843,6 +1843,16 @@ fun! Test_normal33_g_cmd2()
bw! bw!
endfunc 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() func Test_g_ctrl_g()
new new