mirror of
https://github.com/neovim/neovim
synced 2025-07-20 03:02:17 +00:00
fix(input): allow Ctrl-C to interrupt a recursive mapping even if mapped
(cherry picked from commit 56895cf4de
)
This commit is contained in:
committed by
github-actions[bot]
parent
f0f63502ce
commit
1496f4212b
@ -2184,19 +2184,19 @@ static int vgetorpeek(bool advance)
|
|||||||
// try re-mapping.
|
// try re-mapping.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
check_end_reg_executing(advance);
|
check_end_reg_executing(advance);
|
||||||
// os_breakcheck() can call input_enqueue()
|
|
||||||
if ((mapped_ctrl_c | curbuf->b_mapped_ctrl_c) & get_real_state()) {
|
|
||||||
ctrl_c_interrupts = false;
|
|
||||||
}
|
|
||||||
// os_breakcheck() is slow, don't use it too often when
|
// os_breakcheck() is slow, don't use it too often when
|
||||||
// inside a mapping. But call it each time for typed
|
// inside a mapping. But call it each time for typed
|
||||||
// characters.
|
// characters.
|
||||||
if (typebuf.tb_maplen) {
|
if (typebuf.tb_maplen) {
|
||||||
line_breakcheck();
|
line_breakcheck();
|
||||||
} else {
|
} else {
|
||||||
os_breakcheck(); // check for CTRL-C
|
// os_breakcheck() can call input_enqueue()
|
||||||
|
if ((mapped_ctrl_c | curbuf->b_mapped_ctrl_c) & get_real_state()) {
|
||||||
|
ctrl_c_interrupts = false;
|
||||||
}
|
}
|
||||||
|
os_breakcheck(); // check for CTRL-C
|
||||||
ctrl_c_interrupts = true;
|
ctrl_c_interrupts = true;
|
||||||
|
}
|
||||||
int keylen = 0;
|
int keylen = 0;
|
||||||
if (got_int) {
|
if (got_int) {
|
||||||
// flush all input
|
// flush all input
|
||||||
|
@ -72,4 +72,23 @@ describe("CTRL-C (mapped)", function()
|
|||||||
-- INSERT -- |
|
-- INSERT -- |
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('interrupts recursive mapping', function()
|
||||||
|
command('nnoremap <C-C> <Nop>')
|
||||||
|
command('nmap <F2> <Ignore><F2>')
|
||||||
|
feed('<F2>')
|
||||||
|
sleep(10)
|
||||||
|
feed('foo<C-C>')
|
||||||
|
-- wait for input buffer to be flushed
|
||||||
|
sleep(10)
|
||||||
|
feed('i')
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
-- INSERT -- |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
Reference in New Issue
Block a user