Skip to content

Commit 4b41c28

Browse files
zeertzjqgithub-actions[bot]
authored andcommitted
fix(terminal): <Ignore> should be no-op (#37494)
(cherry picked from commit 196df35)
1 parent 40c974e commit 4b41c28

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

src/nvim/os/pty_conpty_win.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void os_conpty_set_size(conpty_t *conpty_object, uint16_t width, uint16_t height
169169
assert(height <= SHRT_MAX);
170170
COORD size = { (int16_t)width, (int16_t)height };
171171
if (pResizePseudoConsole(conpty_object->pty, size) != S_OK) {
172-
ELOG("ResizePseudoConsoel failed: error code: %d",
172+
ELOG("ResizePseudoConsole failed: error code: %d",
173173
os_translate_sys_error((int)GetLastError()));
174174
}
175175
}

src/nvim/terminal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,11 @@ static int terminal_execute(VimState *state, int key)
10221022
map_execute_lua(false);
10231023
break;
10241024

1025+
case K_IGNORE:
1026+
case K_NOP:
1027+
// Do not interrupt a Ctrl-\ sequence or close a finished terminal.
1028+
break;
1029+
10251030
case Ctrl_N:
10261031
if (s->got_bsl) {
10271032
return 0;

test/functional/terminal/buffer_spec.lua

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,14 +1139,18 @@ describe('on_lines does not emit out-of-bounds line indexes when', function()
11391139
end)
11401140

11411141
describe('terminal input', function()
1142+
local chan --- @type integer
1143+
11421144
before_each(function()
11431145
clear()
1144-
exec_lua([[
1146+
chan = exec_lua(function()
11451147
_G.input_data = ''
1146-
vim.api.nvim_open_term(0, { on_input = function(_, _, _, data)
1147-
_G.input_data = _G.input_data .. data
1148-
end })
1149-
]])
1148+
return vim.api.nvim_open_term(0, {
1149+
on_input = function(_, _, _, data)
1150+
_G.input_data = _G.input_data .. data
1151+
end,
1152+
})
1153+
end)
11501154
feed('i')
11511155
poke_eventloop()
11521156
end)
@@ -1160,6 +1164,35 @@ describe('terminal input', function()
11601164
feed('aaa<Help>bbb')
11611165
eq('aaabbb', exec_lua([[return _G.input_data]]))
11621166
end)
1167+
1168+
it('<Ignore> is no-op', function()
1169+
feed('aaa<Ignore>bbb')
1170+
eq('aaabbb', exec_lua([[return _G.input_data]]))
1171+
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
1172+
feed([[<C-\><Ignore><C-N>]])
1173+
eq({ mode = 'nt', blocking = false }, api.nvim_get_mode())
1174+
feed('v')
1175+
eq({ mode = 'v', blocking = false }, api.nvim_get_mode())
1176+
feed('<Esc>')
1177+
eq({ mode = 'nt', blocking = false }, api.nvim_get_mode())
1178+
feed('i')
1179+
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
1180+
feed([[<C-\><Ignore><C-O>]])
1181+
eq({ mode = 'ntT', blocking = false }, api.nvim_get_mode())
1182+
feed('v')
1183+
eq({ mode = 'v', blocking = false }, api.nvim_get_mode())
1184+
feed('<Esc>')
1185+
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
1186+
fn.chanclose(chan)
1187+
feed('<MouseMove>')
1188+
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
1189+
feed('<Ignore>')
1190+
eq({ mode = 't', blocking = false }, api.nvim_get_mode())
1191+
eq('terminal', api.nvim_get_option_value('buftype', { buf = 0 }))
1192+
feed('<Space>')
1193+
eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
1194+
eq('', api.nvim_get_option_value('buftype', { buf = 0 }))
1195+
end)
11631196
end)
11641197

11651198
describe('terminal input', function()

0 commit comments

Comments
 (0)