patch 8.2.4173: cannot use an import in 'foldexpr'
Problem: Cannot use an import in 'foldexpr'.
Solution: Set the script context to where 'foldexpr' was set. (closes #9584)
Fix that the script context was not set for all buffers.
diff --git a/src/eval.c b/src/eval.c
index 9313c27..ec34ef1 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -772,7 +772,7 @@
return rettv.vval.v_list;
}
-#ifdef FEAT_FOLDING
+#if defined(FEAT_FOLDING) || defined(PROTO)
/*
* Evaluate "arg", which is 'foldexpr'.
* Note: caller must set "curwin" to match "arg".
@@ -780,14 +780,19 @@
* give error messages.
*/
int
-eval_foldexpr(char_u *arg, int *cp)
+eval_foldexpr(win_T *wp, int *cp)
{
+ char_u *arg;
typval_T tv;
varnumber_T retval;
char_u *s;
+ sctx_T saved_sctx = current_sctx;
int use_sandbox = was_set_insecurely((char_u *)"foldexpr",
OPT_LOCAL);
+ arg = wp->w_p_fde;
+ current_sctx = wp->w_p_script_ctx[WV_FDE];
+
++emsg_off;
if (use_sandbox)
++sandbox;
@@ -818,6 +823,7 @@
--sandbox;
--textwinlock;
clear_evalarg(&EVALARG_EVALUATE, NULL);
+ current_sctx = saved_sctx;
return (int)retval;
}