From 913e81c35f162c1e2647565397608f63f38d7043 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 9 Jan 2025 14:05:40 +0100 Subject: fix(getchar): do not simplify keycodes in terminal mode The code represents a useful pattern in normal mode where remapping `` will implicitly also remap `` unless you remap that explicitly. This relies on the _unmapped_ behavior being identical which is not true in terminal mode, as vterm can distinguish these keys. Vim seems to entangle this with kitty keyboard mode detection which is irrelevant for us. Conditional fallbacks depending on keyboard mode could be done completely inside `vterm/` without getchar.c getting involved, I would think. --- test/functional/terminal/buffer_spec.lua | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'test/functional/terminal/buffer_spec.lua') diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index cc807ba555..50e23d9e23 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -625,6 +625,74 @@ describe('terminal input', function() ]]):format(key)) end end) + + -- TODO(bfredl): getcharstr() erases the distinction between and . + -- If it was enhanced or replaced this could get folded into the test above. + it('can send TAB/C-I and ESC/C-[ separately', function() + clear() + local screen = tt.setup_child_nvim({ + '-u', + 'NONE', + '-i', + 'NONE', + '--cmd', + 'colorscheme vim', + '--cmd', + 'set notermguicolors', + '--cmd', + 'noremap echo "Tab!"', + '--cmd', + 'noremap echo "Ctrl-I!"', + '--cmd', + 'noremap echo "Esc!"', + '--cmd', + 'noremap echo "Ctrl-[!"', + }) + + screen:expect([[ + ^ | + {4:~ }|*3 + {5:[No Name] 0,0-1 All}| + | + {3:-- TERMINAL --} | + ]]) + + feed('') + screen:expect([[ + ^ | + {4:~ }|*3 + {5:[No Name] 0,0-1 All}| + Tab! | + {3:-- TERMINAL --} | + ]]) + + feed('') + screen:expect([[ + ^ | + {4:~ }|*3 + {5:[No Name] 0,0-1 All}| + Ctrl-I! | + {3:-- TERMINAL --} | + ]]) + + feed('') + screen:expect([[ + ^ | + {4:~ }|*3 + {5:[No Name] 0,0-1 All}| + Esc! | + {3:-- TERMINAL --} | + ]]) + + feed('') + screen:expect([[ + ^ | + {4:~ }|*3 + {5:[No Name] 0,0-1 All}| + Ctrl-[! | + {3:-- TERMINAL --} | + ]]) + end) end) if is_os('win') then -- cgit