aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-27 06:02:13 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-07-27 06:19:43 +0800
commit9f1dc1466e0391c9f592455136f5a07106acf150 (patch)
tree04e371645c8ca4395c2552789381f1fb81dd339e /src
parent45e2bbae835fab479f8e900a2f9c7c47ae22caea (diff)
downloadrneovim-9f1dc1466e0391c9f592455136f5a07106acf150.tar.gz
rneovim-9f1dc1466e0391c9f592455136f5a07106acf150.tar.bz2
rneovim-9f1dc1466e0391c9f592455136f5a07106acf150.zip
vim-patch:9.0.0082: cannot interrupt global command from command line
Problem: Cannot interrupt global command from command line. Solution: Reset got_int in another place. (closes vim/vim#10739) https://github.com/vim/vim/commit/3cfae39b087c2724991d385e5e8ee7d011aa8e99
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_getln.c5
-rw-r--r--src/nvim/testdir/test_ex_mode.vim1
-rw-r--r--src/nvim/testdir/test_global.vim30
3 files changed, 33 insertions, 3 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 8c8f8cec4b..a29063bf91 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1006,8 +1006,6 @@ static int command_line_check(VimState *state)
// that occurs while typing a command should
// cause the command not to be executed.
- got_int = false; // avoid infinite Ctrl-C loop in Ex mode
-
cursorcmd(); // set the cursor on the right spot
ui_cursor_shape();
return 1;
@@ -1070,7 +1068,8 @@ static int command_line_execute(VimState *state, int key)
// Don't ignore it for the input() function.
if ((s->c == Ctrl_C)
&& s->firstc != '@'
- && !s->break_ctrl_c
+ // do clear got_int in Ex mode to avoid infinite Ctrl-C loop
+ && (!s->break_ctrl_c || exmode_active)
&& !global_busy) {
got_int = false;
}
diff --git a/src/nvim/testdir/test_ex_mode.vim b/src/nvim/testdir/test_ex_mode.vim
index c6bd234e65..2f734cba26 100644
--- a/src/nvim/testdir/test_ex_mode.vim
+++ b/src/nvim/testdir/test_ex_mode.vim
@@ -146,6 +146,7 @@ func Test_Ex_append_in_loop()
call term_sendkeys(buf, "append\<CR>")
call WaitForAssert({-> assert_match(': append', term_getline(buf, 5))}, 1000)
call term_sendkeys(buf, "\<C-C>")
+ " Wait for input to be flushed
call term_wait(buf)
call term_sendkeys(buf, "foo\<CR>")
call WaitForAssert({-> assert_match('foo', term_getline(buf, 5))}, 1000)
diff --git a/src/nvim/testdir/test_global.vim b/src/nvim/testdir/test_global.vim
index feddf85346..947f7efc7c 100644
--- a/src/nvim/testdir/test_global.vim
+++ b/src/nvim/testdir/test_global.vim
@@ -1,4 +1,7 @@
+" Test for :global and :vglobal
+
source check.vim
+source term_util.vim
func Test_yank_put_clipboard()
new
@@ -82,4 +85,31 @@ func Test_wrong_delimiter()
call assert_fails('g x^bxd', 'E146:')
endfunc
+" Test for interrupting :global using Ctrl-C
+func Test_interrupt_global()
+ CheckRunVimInTerminal
+ let lines =<< trim END
+ cnoremap ; <Cmd>sleep 10<CR>
+ call setline(1, repeat(['foo'], 5))
+ END
+ call writefile(lines, 'Xtest_interrupt_global')
+ let buf = RunVimInTerminal('-S Xtest_interrupt_global', {'rows': 6})
+
+ call term_sendkeys(buf, ":g/foo/norm :\<C-V>;\<CR>")
+ " Wait for :sleep to start
+ call term_wait(buf)
+ call term_sendkeys(buf, "\<C-C>")
+ call WaitForAssert({-> assert_match('Interrupted', term_getline(buf, 6))}, 1000)
+
+ " Also test in Ex mode
+ call term_sendkeys(buf, "gQg/foo/norm :\<C-V>;\<CR>")
+ " Wait for :sleep to start
+ call term_wait(buf)
+ call term_sendkeys(buf, "\<C-C>")
+ call WaitForAssert({-> assert_match('Interrupted', term_getline(buf, 5))}, 1000)
+
+ call StopVimInTerminal(buf)
+ call delete('Xtest_interrupt_global')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab