Merge pull request #24379 from neovim/backport-24378-to-release-0.9

[Backport release-0.9] fix(terminal): don't send unknown special keys to terminal
This commit is contained in:
zeertzjq
2023-07-17 21:53:33 +08:00
committed by GitHub
2 changed files with 25 additions and 1 deletions

View File

@@ -765,7 +765,7 @@ void terminal_send_key(Terminal *term, int c)
if (key) { if (key) {
vterm_keyboard_key(term->vt, key, mod); vterm_keyboard_key(term->vt, key, mod);
} else { } else if (!IS_SPECIAL(c)) {
vterm_keyboard_unichar(term->vt, (uint32_t)c, mod); vterm_keyboard_unichar(term->vt, (uint32_t)c, mod);
} }
} }

View File

@@ -430,6 +430,30 @@ it('terminal truncates number of composing characters to 5', function()
retry(nil, nil, function() eq('a' .. composing:rep(5), meths.get_current_line()) end) retry(nil, nil, function() eq('a' .. composing:rep(5), meths.get_current_line()) end)
end) end)
describe('terminal input', function()
before_each(function()
clear()
exec_lua([[
_G.input_data = ''
vim.api.nvim_open_term(0, { on_input = function(_, _, _, data)
_G.input_data = _G.input_data .. data
end })
]])
command('startinsert')
poke_eventloop()
end)
it('<C-Space> is sent as NUL byte', function()
feed('aaa<C-Space>bbb')
eq('aaa\0bbb', exec_lua([[return _G.input_data]]))
end)
it('unknown special keys are not sent', function()
feed('aaa<Help>bbb')
eq('aaabbb', exec_lua([[return _G.input_data]]))
end)
end)
if is_os('win') then if is_os('win') then
describe(':terminal in Windows', function() describe(':terminal in Windows', function()
local screen local screen