diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-29 18:37:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 18:37:07 +0800 |
commit | f29c41d665fde8e03848db12093219466deceda2 (patch) | |
tree | e7b8c7f926e6f3097bd3992fbae507ddf3c0eb46 /test/functional/lua/vim_spec.lua | |
parent | fc19ee01acc30bac371f5a56a97a5cdfe8094014 (diff) | |
download | rneovim-f29c41d665fde8e03848db12093219466deceda2.tar.gz rneovim-f29c41d665fde8e03848db12093219466deceda2.tar.bz2 rneovim-f29c41d665fde8e03848db12093219466deceda2.zip |
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.
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 20 |
1 files changed, 17 insertions, 3 deletions
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 å <ESC>', exec_lua [[return table.concat(keys, '')]]) + eq('inext 🤦 lines å …<ESC>', 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<C-V><C-;><C-V><C-…><Esc>]]) + + eq('i<C-V><C-;><C-V><C-…><Esc>', exec_lua [[return table.concat(keys, '')]]) end) it('allows removing on_key listeners', function() |