summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-21 16:31:11 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-21 16:31:11 +0000
commite70dd11ef41f69bd5e94f630194e6b3c4f3f2102 (patch)
tree52b2b8861caa9630a3dcd58e9f217a1b675515e7 /src/eval.c
parent6517f14165cdebf83a07ab9d4aeeb102b4e16e92 (diff)
patch 8.2.4173: cannot use an import in 'foldexpr'v8.2.4173
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.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c
index 9313c27207..ec34ef13e2 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -772,7 +772,7 @@ call_func_retlist(
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 @@ call_func_retlist(
* 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 @@ eval_foldexpr(char_u *arg, int *cp)
--sandbox;
--textwinlock;
clear_evalarg(&EVALARG_EVALUATE, NULL);
+ current_sctx = saved_sctx;
return (int)retval;
}