From f29c41d665fde8e03848db12093219466deceda2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 29 Mar 2024 18:37:07 +0800 Subject: test: add a bit more testing for vim.on_key() (#28095) Also: - Don't use NUMBUFLEN as buffer length as its unrelated. - Restore accidentally removed comment from last commit. --- test/functional/lua/vim_spec.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 7ab009659b..62ca20d599 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -3007,7 +3007,7 @@ describe('lua stdlib', function() end) describe('vim.on_key', function() - it('tracks keystrokes', function() + it('tracks Unicode input', function() insert([[hello world ]]) exec_lua [[ @@ -3022,10 +3022,24 @@ describe('lua stdlib', function() end) ]] - insert([[next 🤦 lines å ]]) + insert([[next 🤦 lines å …]]) -- It has escape in the keys pressed - eq('inext 🤦 lines å ', exec_lua [[return table.concat(keys, '')]]) + eq('inext 🤦 lines å …', exec_lua [[return table.concat(keys, '')]]) + end) + + it('tracks input with modifiers', function() + exec_lua [[ + keys = {} + + vim.on_key(function(buf) + table.insert(keys, vim.fn.keytrans(buf)) + end) + ]] + + feed([[i]]) + + eq('i', exec_lua [[return table.concat(keys, '')]]) end) it('allows removing on_key listeners', function() -- cgit