fix(terminal): send Shift-Home Shift-End Ctrl-Home Ctrl-End (#24418)

This commit is contained in:
zeertzjq 2023-07-22 08:00:42 +08:00 committed by GitHub
parent 02d859a073
commit b74262a336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 0 deletions

View File

@ -1095,6 +1095,8 @@ static void convert_modifiers(int key, VTermModifier *statep)
case K_S_DOWN:
case K_S_LEFT:
case K_S_RIGHT:
case K_S_HOME:
case K_S_END:
case K_S_F1:
case K_S_F2:
case K_S_F3:
@ -1112,6 +1114,8 @@ static void convert_modifiers(int key, VTermModifier *statep)
case K_C_LEFT:
case K_C_RIGHT:
case K_C_HOME:
case K_C_END:
*statep |= VTERM_MOD_CTRL;
break;
}
@ -1158,8 +1162,16 @@ static VTermKey convert_key(int key, VTermModifier *statep)
return VTERM_KEY_INS;
case K_DEL:
return VTERM_KEY_DEL;
case K_S_HOME:
FALLTHROUGH;
case K_C_HOME:
FALLTHROUGH;
case K_HOME:
return VTERM_KEY_HOME;
case K_S_END:
FALLTHROUGH;
case K_C_END:
FALLTHROUGH;
case K_END:
return VTERM_KEY_END;
case K_PAGEUP:

View File

@ -17,6 +17,7 @@ local sleep = helpers.sleep
local funcs = helpers.funcs
local is_os = helpers.is_os
local skip = helpers.skip
local nvim_prog = helpers.nvim_prog
describe(':terminal buffer', function()
local screen
@ -455,6 +456,33 @@ describe('terminal input', function()
end)
end)
describe('terminal input', function()
it('sends various special keys with modifiers', function()
clear()
local screen = thelpers.screen_setup(0,
string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--cmd", "startinsert"]]=], nvim_prog))
screen:expect{grid=[[
{1: } |
{4:~ }|
{4:~ }|
{4:~ }|
{5:[No Name] 0,1 All}|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]]}
for _, key in ipairs({
'<M-Tab>', '<M-CR>', '<M-Esc>',
'<BS>', '<S-Tab>', '<Insert>', '<Del>', '<PageUp>', '<PageDown>',
'<S-Up>', '<C-Up>', '<Up>', '<S-Down>', '<C-Down>', '<Down>',
'<S-Left>', '<C-Left>', '<Left>', '<S-Right>', '<C-Right>', '<Right>',
'<S-Home>', '<C-Home>', '<Home>', '<S-End>', '<C-End>', '<End>',
}) do
feed('<CR><C-V>' .. key)
retry(nil, nil, function() eq(key, meths.get_current_line()) end)
end
end)
end)
if is_os('win') then
describe(':terminal in Windows', function()
local screen