From f5518b78c843e4b187bd246d31bb7fde2925139e Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Fri, 7 Jan 2022 18:31:17 +0600 Subject: chore: improve lua keymaps internal representation scheme --- src/nvim/getchar.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 5d8a8ddbfe..217477246e 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2679,8 +2679,7 @@ void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, mapargs->orig_rhs_len = 0; // stores ref_no in map_str mapargs->rhs_len = (size_t)vim_snprintf(S_LEN(tmp_buf), "%c%c%c%d\r", K_SPECIAL, - (char_u)KEY2TERMCAP0(K_LUA), KEY2TERMCAP1(K_LUA), - rhs_lua); + (char_u)KS_EXTRA, KE_LUA, rhs_lua); mapargs->rhs = vim_strsave((char_u *)tmp_buf); } -- cgit From 07a98b1a75b8c4995ecf8b0e947a1909d91a3d51 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Wed, 16 Feb 2022 12:22:15 +0600 Subject: fix: not shown in :map commands --- src/nvim/getchar.c | 2 +- test/functional/api/keymap_spec.lua | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 217477246e..cc653bb4e9 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -3483,7 +3483,7 @@ static void showmap(mapblock_T *mp, bool local) char msg[100]; snprintf(msg, sizeof(msg), "", mp->m_luaref); msg_puts_attr(msg, HL_ATTR(HLF_8)); - } else if (mp->m_str == NULL) { + } else if (mp->m_str[0] == NUL) { msg_puts_attr("", HL_ATTR(HLF_8)); } else { // Remove escaping of K_SPECIAL, because "m_str" is in a format to be used diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 450a76ddac..06b699193a 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -1037,4 +1037,9 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function() eq(1, exec_lua[[return GlobalCount]]) eq('\nNo mapping found', helpers.exec_capture('nmap asdf')) end) + + it ('shows as map rhs', function() + meths.set_keymap('n', 'asdf', '', {}) + eq('\nn asdf ', helpers.exec_capture('nmap asdf')) + end) end) -- cgit