fix(terminal): <Ignore> should be no-op (#37494)

This commit is contained in:
zeertzjq
2026-01-22 09:26:22 +08:00
committed by GitHub
parent c68e9d2a59
commit 196df35cca
3 changed files with 44 additions and 6 deletions

View File

@@ -169,7 +169,7 @@ void os_conpty_set_size(conpty_t *conpty_object, uint16_t width, uint16_t height
assert(height <= SHRT_MAX);
COORD size = { (int16_t)width, (int16_t)height };
if (pResizePseudoConsole(conpty_object->pty, size) != S_OK) {
ELOG("ResizePseudoConsoel failed: error code: %d",
ELOG("ResizePseudoConsole failed: error code: %d",
os_translate_sys_error((int)GetLastError()));
}
}

View File

@@ -1030,6 +1030,11 @@ static int terminal_execute(VimState *state, int key)
map_execute_lua(false, false);
break;
case K_IGNORE:
case K_NOP:
// Do not interrupt a Ctrl-\ sequence or close a finished terminal.
break;
case Ctrl_N:
if (s->got_bsl) {
return 0;

View File

@@ -1152,14 +1152,18 @@ describe('on_lines does not emit out-of-bounds line indexes when', function()
end)
describe('terminal input', function()
local chan --- @type integer
before_each(function()
clear()
exec_lua([[
chan = exec_lua(function()
_G.input_data = ''
vim.api.nvim_open_term(0, { on_input = function(_, _, _, data)
_G.input_data = _G.input_data .. data
end })
]])
return vim.api.nvim_open_term(0, {
on_input = function(_, _, _, data)
_G.input_data = _G.input_data .. data
end,
})
end)
feed('i')
poke_eventloop()
end)
@@ -1173,6 +1177,35 @@ describe('terminal input', function()
feed('aaa<Help>bbb')
eq('aaabbb', exec_lua([[return _G.input_data]]))
end)
it('<Ignore> is no-op', function()
feed('aaa<Ignore>bbb')
eq('aaabbb', exec_lua([[return _G.input_data]]))
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
feed([[<C-\><Ignore><C-N>]])
eq({ mode = 'nt', blocking = false }, api.nvim_get_mode())
feed('v')
eq({ mode = 'v', blocking = false }, api.nvim_get_mode())
feed('<Esc>')
eq({ mode = 'nt', blocking = false }, api.nvim_get_mode())
feed('i')
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
feed([[<C-\><Ignore><C-O>]])
eq({ mode = 'ntT', blocking = false }, api.nvim_get_mode())
feed('v')
eq({ mode = 'v', blocking = false }, api.nvim_get_mode())
feed('<Esc>')
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
fn.chanclose(chan)
feed('<MouseMove>')
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
feed('<Ignore>')
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
eq('terminal', api.nvim_get_option_value('buftype', { buf = 0 }))
feed('<Space>')
eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
eq('', api.nvim_get_option_value('buftype', { buf = 0 }))
end)
end)
describe('terminal input', function()