patch 8.2.4059: Vim9: an expression of a map cannot access script-local items
Problem: Vim9: an expression of a map cannot access script-local items.
(Maxim Kim)
Solution: Use the script ID of where the map was defined.
diff --git a/src/getchar.c b/src/getchar.c
index 6fecc1a..08c1a95 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -2785,7 +2785,6 @@
int save_m_noremap;
int save_m_silent;
char_u *save_m_keys;
- char_u *save_m_str;
#else
# define save_m_noremap mp->m_noremap
# define save_m_silent mp->m_silent
@@ -2834,7 +2833,6 @@
save_m_noremap = mp->m_noremap;
save_m_silent = mp->m_silent;
save_m_keys = NULL; // only saved when needed
- save_m_str = NULL; // only saved when needed
/*
* Handle ":map <expr>": evaluate the {rhs} as an expression. Also
@@ -2851,8 +2849,7 @@
may_garbage_collect = FALSE;
save_m_keys = vim_strsave(mp->m_keys);
- save_m_str = vim_strsave(mp->m_str);
- map_str = eval_map_expr(save_m_str, NUL);
+ map_str = eval_map_expr(mp, NUL);
// The mapping may do anything, but we expect it to take care of
// redrawing. Do put the cursor back where it was.
@@ -2900,7 +2897,6 @@
}
#ifdef FEAT_EVAL
vim_free(save_m_keys);
- vim_free(save_m_str);
#endif
*keylenp = keylen;
if (i == FAIL)