patch 9.0.1687: mapset() not properly handling script ID
Problem: mapset() not properly handling script ID
Solution: replace_termcodes() may accept a script ID
closes: #12699
closes: #12697
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
diff --git a/src/map.c b/src/map.c
index 6020f63..5988445 100644
--- a/src/map.c
+++ b/src/map.c
@@ -590,9 +590,9 @@
if (special)
flags |= REPTERM_SPECIAL;
- new_keys = replace_termcodes(keys, &keys_buf, flags, &did_simplify);
+ new_keys = replace_termcodes(keys, &keys_buf, 0, flags, &did_simplify);
if (did_simplify)
- (void)replace_termcodes(keys, &alt_keys_buf,
+ (void)replace_termcodes(keys, &alt_keys_buf, 0,
flags | REPTERM_NO_SIMPLIFY, NULL);
keys = new_keys;
}
@@ -602,7 +602,7 @@
if (STRICMP(rhs, "<nop>") == 0) // "<Nop>" means nothing
rhs = (char_u *)"";
else
- rhs = replace_termcodes(rhs, &arg_buf,
+ rhs = replace_termcodes(rhs, &arg_buf, 0,
REPTERM_DO_LT | (special ? REPTERM_SPECIAL : 0), NULL);
}
@@ -1133,7 +1133,7 @@
char_u *buf;
int retval;
- rhs = replace_termcodes(str, &buf, REPTERM_DO_LT, NULL);
+ rhs = replace_termcodes(str, &buf, 0, REPTERM_DO_LT, NULL);
retval = map_to_exists_mode(rhs, mode_str2flags(modechars), abbr);
vim_free(buf);
@@ -2488,14 +2488,15 @@
mode = get_map_mode(&which, 0);
- keys_simplified = replace_termcodes(keys, &keys_buf, flags, &did_simplify);
+ keys_simplified = replace_termcodes(keys, &keys_buf, 0, flags,
+ &did_simplify);
rhs = check_map(keys_simplified, mode, exact, FALSE, abbr,
&mp, &buffer_local);
if (did_simplify)
{
// When the lhs is being simplified the not-simplified keys are
// preferred for printing, like in do_map().
- (void)replace_termcodes(keys, &alt_keys_buf,
+ (void)replace_termcodes(keys, &alt_keys_buf, 0,
flags | REPTERM_NO_SIMPLIFY, NULL);
rhs = check_map(alt_keys_buf, mode, exact, FALSE, abbr, &mp,
&buffer_local);
@@ -2579,7 +2580,8 @@
did_simplify = FALSE;
lhs = str2special_save(mp->m_keys, TRUE, FALSE);
- (void)replace_termcodes(lhs, &keys_buf, flags, &did_simplify);
+ (void)replace_termcodes(lhs, &keys_buf, 0, flags,
+ &did_simplify);
vim_free(lhs);
mapblock2dict(mp, d,
@@ -2758,11 +2760,6 @@
return;
}
orig_rhs = rhs;
- if (STRICMP(rhs, "<nop>") == 0) // "<Nop>" means nothing
- rhs = (char_u *)"";
- else
- rhs = replace_termcodes(rhs, &arg_buf,
- REPTERM_DO_LT | REPTERM_SPECIAL, NULL);
noremap = dict_get_number(d, "noremap") ? REMAP_NONE: 0;
if (dict_get_number(d, "script") != 0)
@@ -2776,6 +2773,12 @@
nowait = dict_get_number(d, "nowait") != 0;
// mode from the dict is not used
+ if (STRICMP(rhs, "<nop>") == 0) // "<Nop>" means nothing
+ rhs = (char_u *)"";
+ else
+ rhs = replace_termcodes(rhs, &arg_buf, sid,
+ REPTERM_DO_LT | REPTERM_SPECIAL, NULL);
+
if (buffer)
{
map_table = curbuf->b_maphash;