diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-31 11:20:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-31 11:20:05 +0800 |
commit | e1ff2c51cad755d0ddc04a23df23e317d77023ed (patch) | |
tree | a32389bcb708f2b0efed0134ffafc206b527db08 /src/nvim/lua/executor.c | |
parent | 12240600f5d2c992aa77bc4592edc16814abfafd (diff) | |
download | rneovim-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 'src/nvim/lua/executor.c')
-rw-r--r-- | src/nvim/lua/executor.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 9e4b698b69..cfc68dc08f 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -2064,7 +2064,7 @@ char *nlua_register_table_as_callable(const typval_T *const arg) return name; } -void nlua_execute_on_key(int c) +void nlua_execute_on_key(int c, char *typed_buf, size_t typed_len) { char buf[MB_MAXBYTES * 3 + 4]; size_t buf_len = special_to_buf(c, mod_mask, false, buf); @@ -2085,9 +2085,12 @@ void nlua_execute_on_key(int c) // [ vim, vim._on_key, buf ] lua_pushlstring(lstate, buf, buf_len); + // [ vim, vim._on_key, buf, typed_buf ] + lua_pushlstring(lstate, typed_buf, typed_len); + int save_got_int = got_int; got_int = false; // avoid interrupts when the key typed is Ctrl-C - if (nlua_pcall(lstate, 1, 0)) { + if (nlua_pcall(lstate, 2, 0)) { nlua_error(lstate, _("Error executing vim.on_key Lua callback: %.*s")); } |