diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-07-03 23:33:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-03 23:33:08 +0200 |
commit | 008b604bacbbeeaf0e04f94b1d331b11ebec631a (patch) | |
tree | 45a004c00c61f0bbe84cbf291093b6dffcf0bfb1 /src/nvim/eval.c | |
parent | e333957a1a9ae64b7daa36e08fd1df583114d4ba (diff) | |
parent | 35898cff5d1d6dc60e0d7b87bfe106539453b031 (diff) | |
download | rneovim-008b604bacbbeeaf0e04f94b1d331b11ebec631a.tar.gz rneovim-008b604bacbbeeaf0e04f94b1d331b11ebec631a.tar.bz2 rneovim-008b604bacbbeeaf0e04f94b1d331b11ebec631a.zip |
Merge #6947 from ZyX-I/consistent-get_keymap
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 18aa5bf763..662270e788 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12117,9 +12117,11 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) xfree(keys_buf); if (!get_dict) { - /* Return a string. */ - if (rhs != NULL) - rettv->vval.v_string = str2special_save(rhs, FALSE); + // Return a string. + if (rhs != NULL) { + rettv->vval.v_string = (char_u *)str2special_save( + (const char *)rhs, false, false); + } } else { tv_dict_alloc_ret(rettv); @@ -12154,7 +12156,8 @@ void mapblock_fill_dict(dict_T *const dict, bool compatible) FUNC_ATTR_NONNULL_ALL { - char_u *lhs = str2special_save(mp->m_keys, true); + char *const lhs = str2special_save((const char *)mp->m_keys, + compatible, !compatible); char *const mapmode = map_mode_to_chars(mp->m_mode); varnumber_T noremap_value; @@ -12168,18 +12171,21 @@ void mapblock_fill_dict(dict_T *const dict, noremap_value = mp->m_noremap == REMAP_SCRIPT ? 2 : !!mp->m_noremap; } - tv_dict_add_str(dict, S_LEN("lhs"), (const char *)lhs); - tv_dict_add_str(dict, S_LEN("rhs"), (const char *)mp->m_orig_str); + if (compatible) { + tv_dict_add_str(dict, S_LEN("rhs"), (const char *)mp->m_orig_str); + } else { + tv_dict_add_allocated_str(dict, S_LEN("rhs"), + str2special_save((const char *)mp->m_str, false, + true)); + } + tv_dict_add_allocated_str(dict, S_LEN("lhs"), lhs); tv_dict_add_nr(dict, S_LEN("noremap"), noremap_value); tv_dict_add_nr(dict, S_LEN("expr"), mp->m_expr ? 1 : 0); tv_dict_add_nr(dict, S_LEN("silent"), mp->m_silent ? 1 : 0); tv_dict_add_nr(dict, S_LEN("sid"), (varnumber_T)mp->m_script_ID); tv_dict_add_nr(dict, S_LEN("buffer"), (varnumber_T)buffer_value); tv_dict_add_nr(dict, S_LEN("nowait"), mp->m_nowait ? 1 : 0); - tv_dict_add_str(dict, S_LEN("mode"), mapmode); - - xfree(lhs); - xfree(mapmode); + tv_dict_add_allocated_str(dict, S_LEN("mode"), mapmode); } /* |