aboutsummaryrefslogtreecommitdiff
path: root/test/functional/editor
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-31 11:20:05 +0800
committerGitHub <noreply@github.com>2024-03-31 11:20:05 +0800
commite1ff2c51cad755d0ddc04a23df23e317d77023ed (patch)
treea32389bcb708f2b0efed0134ffafc206b527db08 /test/functional/editor
parent12240600f5d2c992aa77bc4592edc16814abfafd (diff)
downloadrneovim-e1ff2c51cad755d0ddc04a23df23e317d77023ed.tar.gz
rneovim-e1ff2c51cad755d0ddc04a23df23e317d77023ed.tar.bz2
rneovim-e1ff2c51cad755d0ddc04a23df23e317d77023ed.zip
feat(lua): pass keys before mapping to vim.on_key() callback (#28098)
Keys before mapping (i.e. typed keys) are passed as the second argument.
Diffstat (limited to 'test/functional/editor')
-rw-r--r--test/functional/editor/meta_key_spec.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/functional/editor/meta_key_spec.lua b/test/functional/editor/meta_key_spec.lua
index b57f5c3c35..e2bdf6ba96 100644
--- a/test/functional/editor/meta_key_spec.lua
+++ b/test/functional/editor/meta_key_spec.lua
@@ -141,4 +141,29 @@ describe('meta-keys #8226 #13042', function()
// This is some text: bar
// This is some text: baz]])
end)
+
+ it('ALT/META with vim.on_key()', function()
+ feed('ifoo<CR>bar<CR>baz<Esc>gg0')
+
+ exec_lua [[
+ keys = {}
+ typed = {}
+
+ vim.on_key(function(buf, typed_buf)
+ table.insert(keys, vim.fn.keytrans(buf))
+ table.insert(typed, vim.fn.keytrans(typed_buf))
+ end)
+ ]]
+
+ -- <M-"> is reinterpreted as <Esc>"
+ feed('qrviw"ayc$FOO.<M-">apq')
+ expect([[
+ FOO.foo
+ bar
+ baz]])
+
+ -- vim.on_key() callback should only receive <Esc>"
+ eq('qrviw"ayc$FOO.<Esc>"apq', exec_lua [[return table.concat(keys, '')]])
+ eq('qrviw"ayc$FOO.<Esc>"apq', exec_lua [[return table.concat(typed, '')]])
+ end)
end)