From fa898b6f92d45c2671f3580f03400d9988c32998 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 22 Jul 2023 06:29:52 +0800 Subject: [PATCH] fix(terminal): send Shift-Home Shift-End Ctrl-Home Ctrl-End --- src/nvim/terminal.c | 12 ++++++++++ test/functional/terminal/buffer_spec.lua | 28 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index caa4674cef..1dacc496b6 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -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: diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 8b43f5cf9c..3bc03a4117 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -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({ + '', '', '', + '', '', '', '', '', '', + '', '', '', '', '', '', + '', '', '', '', '', '', + '', '', '', '', '', '', + }) do + feed('' .. 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