neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 196df35cca7df2f499ce6f1352184bf7034801c7
parent c68e9d2a59414aa3c7f1c27cf7d34b899dc6ac15
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu, 22 Jan 2026 09:26:22 +0800

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


Diffstat:
Msrc/nvim/os/pty_conpty_win.c | 2+-
Msrc/nvim/terminal.c | 5+++++
Mtest/functional/terminal/buffer_spec.lua | 43++++++++++++++++++++++++++++++++++++++-----
3 files changed, 44 insertions(+), 6 deletions(-)

diff --git 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 @@ -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 @@ -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()