vim-patch:8.2.4173: cannot use an import in 'foldexpr' (#25215)

Problem:    Cannot use an import in 'foldexpr'.
Solution:   Set the script context to where 'foldexpr' was set. (closes vim/vim#9584)
            Fix that the script context was not set for all buffers.

e70dd11ef4

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-09-17 21:01:19 +08:00
committed by GitHub
parent 71530cc972
commit 211edceb4f
3 changed files with 10 additions and 3 deletions

View File

@@ -1271,8 +1271,11 @@ void *call_func_retlist(const char *func, int argc, typval_T *argv)
/// it in "*cp". Doesn't give error messages.
int eval_foldexpr(win_T *wp, int *cp)
{
const sctx_T saved_sctx = current_sctx;
const bool use_sandbox = was_set_insecurely(wp, "foldexpr", OPT_LOCAL);
char *arg = wp->w_p_fde;
current_sctx = wp->w_p_script_ctx[WV_FDE].script_ctx;
emsg_off++;
if (use_sandbox) {
@@ -1309,6 +1312,7 @@ int eval_foldexpr(win_T *wp, int *cp)
}
textlock--;
clear_evalarg(&EVALARG_EVALUATE, NULL);
current_sctx = saved_sctx;
return (int)retval;
}