diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-10-12 08:07:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-12 08:07:05 +0800 |
commit | 0e42c81c7fd429529d89458349c7cdde254d5406 (patch) | |
tree | 4504e1e7382f27d80aaf5914d61c3bdf729ee456 /test/functional/lua/vim_spec.lua | |
parent | c49030b75ad8b8a9f8e7f023b0ee5f9c8c40afdd (diff) | |
download | rneovim-0e42c81c7fd429529d89458349c7cdde254d5406.tar.gz rneovim-0e42c81c7fd429529d89458349c7cdde254d5406.tar.bz2 rneovim-0e42c81c7fd429529d89458349c7cdde254d5406.zip |
fix(lua): avoid recursive vim.on_key() callback (#30753)
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 3c65ec664e..793cf7cfd7 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -3223,6 +3223,45 @@ describe('lua stdlib', function() feed('<C-C>') eq('/', exec_lua([[return _G.ctrl_c_cmdtype]])) end) + + it('callback is not invoked recursively #30752', function() + local screen = Screen.new(60, 10) + screen:attach() + exec_lua([[ + vim.on_key(function(key, typed) + vim.api.nvim_echo({ + { 'key_cb\n' }, + { ("KEYCB: key '%s', typed '%s'\n"):format(key, typed) }, + }, false, {}) + end) + ]]) + feed('^') + screen:expect([[ + | + {1:~ }|*5 + {3: }| + key_cb | + KEYCB: key '^', typed '^' | + {6:Press ENTER or type command to continue}^ | + ]]) + feed('<C-C>') + screen:expect([[ + | + {1:~ }|*3 + {3: }| + key_cb | + KEYCB: key '^', typed '^' | + key_cb | + KEYCB: key '{18:^C}', typed '{18:^C}' | + {6:Press ENTER or type command to continue}^ | + ]]) + feed('<C-C>') + screen:expect([[ + ^ | + {1:~ }|*8 + | + ]]) + end) end) describe('vim.wait', function() |