mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(mappings): elide description copy (#29910)
This commit is contained in:
parent
4b852bc555
commit
cd46383667
@ -157,8 +157,8 @@ static void mapblock_free(mapblock_T **mpp)
|
|||||||
NLUA_CLEAR_REF(mp->m_luaref);
|
NLUA_CLEAR_REF(mp->m_luaref);
|
||||||
xfree(mp->m_str);
|
xfree(mp->m_str);
|
||||||
xfree(mp->m_orig_str);
|
xfree(mp->m_orig_str);
|
||||||
|
xfree(mp->m_desc);
|
||||||
}
|
}
|
||||||
xfree(mp->m_desc);
|
|
||||||
*mpp = mp->m_next;
|
*mpp = mp->m_next;
|
||||||
xfree(mp);
|
xfree(mp);
|
||||||
}
|
}
|
||||||
@ -534,10 +534,7 @@ static mapblock_T *map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr
|
|||||||
mp->m_script_ctx.sc_lnum += SOURCING_LNUM;
|
mp->m_script_ctx.sc_lnum += SOURCING_LNUM;
|
||||||
nlua_set_sctx(&mp->m_script_ctx);
|
nlua_set_sctx(&mp->m_script_ctx);
|
||||||
}
|
}
|
||||||
mp->m_desc = NULL;
|
mp->m_desc = args->desc;
|
||||||
if (args->desc != NULL) {
|
|
||||||
mp->m_desc = xstrdup(args->desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the new entry in front of the abbrlist or maphash[] list
|
// add the new entry in front of the abbrlist or maphash[] list
|
||||||
if (is_abbr) {
|
if (is_abbr) {
|
||||||
@ -803,13 +800,13 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
|||||||
// new rhs for existing entry
|
// new rhs for existing entry
|
||||||
mp->m_mode &= ~mode; // remove mode bits
|
mp->m_mode &= ~mode; // remove mode bits
|
||||||
if (mp->m_mode == 0 && !did_it) { // reuse entry
|
if (mp->m_mode == 0 && !did_it) { // reuse entry
|
||||||
XFREE_CLEAR(mp->m_desc);
|
|
||||||
if (mp->m_alt != NULL) {
|
if (mp->m_alt != NULL) {
|
||||||
mp->m_alt = mp->m_alt->m_alt = NULL;
|
mp->m_alt = mp->m_alt->m_alt = NULL;
|
||||||
} else {
|
} else {
|
||||||
NLUA_CLEAR_REF(mp->m_luaref);
|
NLUA_CLEAR_REF(mp->m_luaref);
|
||||||
xfree(mp->m_str);
|
xfree(mp->m_str);
|
||||||
xfree(mp->m_orig_str);
|
xfree(mp->m_orig_str);
|
||||||
|
xfree(mp->m_desc);
|
||||||
}
|
}
|
||||||
mp->m_str = args->rhs;
|
mp->m_str = args->rhs;
|
||||||
mp->m_orig_str = args->orig_rhs;
|
mp->m_orig_str = args->orig_rhs;
|
||||||
@ -824,9 +821,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
|||||||
mp->m_script_ctx = current_sctx;
|
mp->m_script_ctx = current_sctx;
|
||||||
mp->m_script_ctx.sc_lnum += SOURCING_LNUM;
|
mp->m_script_ctx.sc_lnum += SOURCING_LNUM;
|
||||||
nlua_set_sctx(&mp->m_script_ctx);
|
nlua_set_sctx(&mp->m_script_ctx);
|
||||||
if (args->desc != NULL) {
|
mp->m_desc = args->desc;
|
||||||
mp->m_desc = xstrdup(args->desc);
|
|
||||||
}
|
|
||||||
mp_result[keyround - 1] = mp;
|
mp_result[keyround - 1] = mp;
|
||||||
did_it = true;
|
did_it = true;
|
||||||
}
|
}
|
||||||
@ -903,6 +898,7 @@ theend:
|
|||||||
args->rhs = NULL;
|
args->rhs = NULL;
|
||||||
args->orig_rhs = NULL;
|
args->orig_rhs = NULL;
|
||||||
args->rhs_lua = LUA_NOREF;
|
args->rhs_lua = LUA_NOREF;
|
||||||
|
args->desc = NULL;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -2336,7 +2332,7 @@ void f_mapset(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
.silent = tv_dict_get_number(d, "silent") != 0,
|
.silent = tv_dict_get_number(d, "silent") != 0,
|
||||||
.nowait = tv_dict_get_number(d, "nowait") != 0,
|
.nowait = tv_dict_get_number(d, "nowait") != 0,
|
||||||
.replace_keycodes = tv_dict_get_number(d, "replace_keycodes") != 0,
|
.replace_keycodes = tv_dict_get_number(d, "replace_keycodes") != 0,
|
||||||
.desc = tv_dict_get_string(d, "desc", false),
|
.desc = tv_dict_get_string(d, "desc", true),
|
||||||
};
|
};
|
||||||
scid_T sid = (scid_T)tv_dict_get_number(d, "sid");
|
scid_T sid = (scid_T)tv_dict_get_number(d, "sid");
|
||||||
linenr_T lnum = (linenr_T)tv_dict_get_number(d, "lnum");
|
linenr_T lnum = (linenr_T)tv_dict_get_number(d, "lnum");
|
||||||
|
Loading…
Reference in New Issue
Block a user