vim-patch:8.2.4197: cannot use an import in the "expr" part of 'spellsuggest'

Problem:    Cannot use an import in the "expr" part of 'spellsuggest'.
Solution:   Set the script context when evaluating "expr" of 'spellsuggest'.

2a7aa83458

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-04-17 15:30:42 +08:00
parent f560c97059
commit 481c6e6cac

View File

@@ -1085,6 +1085,7 @@ list_T *eval_spell_expr(char *badword, char *expr)
typval_T rettv; typval_T rettv;
list_T *list = NULL; list_T *list = NULL;
char *p = skipwhite(expr); char *p = skipwhite(expr);
const sctx_T saved_sctx = current_sctx;
// Set "v:val" to the bad word. // Set "v:val" to the bad word.
prepare_vimvar(VV_VAL, &save_val); prepare_vimvar(VV_VAL, &save_val);
@@ -1093,6 +1094,10 @@ list_T *eval_spell_expr(char *badword, char *expr)
if (p_verbose == 0) { if (p_verbose == 0) {
emsg_off++; emsg_off++;
} }
sctx_T *ctx = get_option_sctx("spellsuggest");
if (ctx != NULL) {
current_sctx = *ctx;
}
if (eval1(&p, &rettv, &EVALARG_EVALUATE) == OK) { if (eval1(&p, &rettv, &EVALARG_EVALUATE) == OK) {
if (rettv.v_type != VAR_LIST) { if (rettv.v_type != VAR_LIST) {
@@ -1106,6 +1111,7 @@ list_T *eval_spell_expr(char *badword, char *expr)
emsg_off--; emsg_off--;
} }
restore_vimvar(VV_VAL, &save_val); restore_vimvar(VV_VAL, &save_val);
current_sctx = saved_sctx;
return list; return list;
} }