aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-01-27 07:24:25 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-01-27 07:24:25 +0800
commit81950af22d71a42c17ec9ae3f25b69025657cbff (patch)
tree1637667eb3ff4e077d6c69deacb21b41c35ff7af
parent6006e15e7ac055de1e87bbd12d17d017dfa8737f (diff)
downloadrneovim-81950af22d71a42c17ec9ae3f25b69025657cbff.tar.gz
rneovim-81950af22d71a42c17ec9ae3f25b69025657cbff.tar.bz2
rneovim-81950af22d71a42c17ec9ae3f25b69025657cbff.zip
refactor: allocate an empty string as unused orig_rhs for Lua mappings
-rw-r--r--src/nvim/getchar.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index ef590adb3a..0b47c5e1b0 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -2640,9 +2640,10 @@ void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len,
}
} else {
char tmp_buf[64];
+ // orig_rhs is not used for Lua mappings, but still needs to be a string.
+ mapargs->orig_rhs = xcalloc(1, sizeof(char_u));
+ mapargs->orig_rhs_len = 0;
// stores <lua>ref_no<cr> in map_str
- mapargs->orig_rhs_len = (size_t)vim_snprintf(S_LEN(tmp_buf), "<LUA>%d<CR>", rhs_lua);
- mapargs->orig_rhs = vim_strsave((char_u *)tmp_buf);
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);