diff --git a/src/nvim/os/pty_conpty_win.c b/src/nvim/os/pty_conpty_win.c index 90adb07b0b..d511a5b88a 100644 --- a/src/nvim/os/pty_conpty_win.c +++ b/src/nvim/os/pty_conpty_win.c @@ -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())); } } diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 5c11efc18e..c985665b4f 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -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; diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 586cf0020c..854fd85ada 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -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('aaabbb') eq('aaabbb', exec_lua([[return _G.input_data]])) end) + + it(' is no-op', function() + feed('aaabbb') + eq('aaabbb', exec_lua([[return _G.input_data]])) + eq({ mode = 't', blocking = false }, api.nvim_get_mode()) + feed([[]]) + eq({ mode = 'nt', blocking = false }, api.nvim_get_mode()) + feed('v') + eq({ mode = 'v', blocking = false }, api.nvim_get_mode()) + feed('') + eq({ mode = 'nt', blocking = false }, api.nvim_get_mode()) + feed('i') + eq({ mode = 't', blocking = false }, api.nvim_get_mode()) + feed([[]]) + eq({ mode = 'ntT', blocking = false }, api.nvim_get_mode()) + feed('v') + eq({ mode = 'v', blocking = false }, api.nvim_get_mode()) + feed('') + eq({ mode = 't', blocking = false }, api.nvim_get_mode()) + fn.chanclose(chan) + feed('') + eq({ mode = 't', blocking = false }, api.nvim_get_mode()) + feed('') + eq({ mode = 't', blocking = false }, api.nvim_get_mode()) + eq('terminal', api.nvim_get_option_value('buftype', { buf = 0 })) + feed('') + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) + eq('', api.nvim_get_option_value('buftype', { buf = 0 })) + end) end) describe('terminal input', function()