Skip to content

Commit f754fe6

Browse files
zeertzjqbrammool
authored andcommitted
patch 9.0.0051: using CTRL-C wih :append may hang Vim
Problem: Using CTRL-C wih :append may hang Vim. Solution: Reset got_int. (closes #10729, closes #10728)
1 parent b26592a commit f754fe6

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/ex_getln.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,8 @@ getcmdline_int(
17861786
// that occurs while typing a command should
17871787
// cause the command not to be executed.
17881788

1789+
got_int = FALSE; // avoid infinite Ctrl-C loop in Ex mode
1790+
17891791
// Trigger SafeState if nothing is pending.
17901792
may_trigger_safestate(xpc.xp_numfiles <= 0);
17911793

src/testdir/test_ex_mode.vim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,29 @@ func Test_Ex_global()
145145
bwipe!
146146
endfunc
147147

148+
" Test for pressing Ctrl-C in :append inside a loop in Ex mode
149+
" This used to hang Vim
150+
func Test_Ex_append_in_loop()
151+
CheckRunVimInTerminal
152+
let buf = RunVimInTerminal('', {'rows': 6})
153+
154+
call term_sendkeys(buf, "gQ")
155+
call term_sendkeys(buf, "for i in range(1)\<CR>")
156+
call term_sendkeys(buf, "append\<CR>")
157+
call WaitForAssert({-> assert_match(': append', term_getline(buf, 5))}, 1000)
158+
call term_sendkeys(buf, "\<C-C>")
159+
call term_wait(buf)
160+
call term_sendkeys(buf, "foo\<CR>")
161+
call WaitForAssert({-> assert_match('foo', term_getline(buf, 5))}, 1000)
162+
call term_sendkeys(buf, ".\<CR>")
163+
call WaitForAssert({-> assert_match('.', term_getline(buf, 5))}, 1000)
164+
call term_sendkeys(buf, "endfor\<CR>")
165+
call term_sendkeys(buf, "vi\<CR>")
166+
call WaitForAssert({-> assert_match('foo', term_getline(buf, 1))}, 1000)
167+
168+
call StopVimInTerminal(buf)
169+
endfunc
170+
148171
" In Ex-mode, a backslash escapes a newline
149172
func Test_Ex_escape_enter()
150173
call feedkeys("gQlet l = \"a\\\<kEnter>b\"\<cr>vi\<cr>", 'xt')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ static char *(features[]) =
735735

736736
static int included_patches[] =
737737
{ /* Add new patch number below this line */
738+
/**/
739+
51,
738740
/**/
739741
50,
740742
/**/

0 commit comments

Comments
 (0)