diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-02-16 16:01:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 16:01:17 +0800 |
commit | deb33a9775f53d2b32aeeb1825e773bccb039ca4 (patch) | |
tree | d19f99712ea85db29de837eaf7f67b949f157342 | |
parent | 9ef56961328991e22110c8084cb23e3ef3adde39 (diff) | |
parent | 07a98b1a75b8c4995ecf8b0e947a1909d91a3d51 (diff) | |
download | rneovim-deb33a9775f53d2b32aeeb1825e773bccb039ca4.tar.gz rneovim-deb33a9775f53d2b32aeeb1825e773bccb039ca4.tar.bz2 rneovim-deb33a9775f53d2b32aeeb1825e773bccb039ca4.zip |
Merge pull request #17422 from shadmansaleh/enhance/maps
fix: <Nop> not shown in :map commands
-rw-r--r-- | src/nvim/getchar.c | 5 | ||||
-rw-r--r-- | test/functional/api/keymap_spec.lua | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 5d8a8ddbfe..cc653bb4e9 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 <lua>ref_no<cr> 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); } @@ -3484,7 +3483,7 @@ static void showmap(mapblock_T *mp, bool local) char msg[100]; snprintf(msg, sizeof(msg), "<Lua function %d>", 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("<Nop>", 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 <nop> as map rhs', function() + meths.set_keymap('n', 'asdf', '<nop>', {}) + eq('\nn asdf <Nop>', helpers.exec_capture('nmap asdf')) + end) end) |