summaryrefslogtreecommitdiff
path: root/src/fold.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-01-22 13:39:08 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-22 13:39:08 +0000
commit9530b580a7b71960dbbdb2b12a3aafeb540bd135 (patch)
tree5e169ea9710cf9d3e1f9dade5ff223c2850a7d59 /src/fold.c
parent0bfa84916d110d4f4d863e91e144ff05ba431316 (diff)
downloadvim-git-9530b580a7b71960dbbdb2b12a3aafeb540bd135.tar.gz
patch 8.2.4179: 'foldtext' is evaluated in the current script contextv8.2.4179
Problem: 'foldtext' is evaluated in the current script context. Solution: Use the script context where the option was set.
Diffstat (limited to 'src/fold.c')
-rw-r--r--src/fold.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/fold.c b/src/fold.c
index 2a45d2108..73c71160b 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -1923,7 +1923,6 @@ get_foldtext(
if (*wp->w_p_fdt != NUL)
{
char_u dashes[MAX_LEVEL + 2];
- win_T *save_curwin;
int level;
char_u *p;
@@ -1941,23 +1940,27 @@ get_foldtext(
set_vim_var_string(VV_FOLDDASHES, dashes, -1);
set_vim_var_nr(VV_FOLDLEVEL, (long)level);
- // skip evaluating foldtext on errors
+ // skip evaluating 'foldtext' on errors
if (!got_fdt_error)
{
- save_curwin = curwin;
+ win_T *save_curwin = curwin;
+ sctx_T saved_sctx = current_sctx;
+
curwin = wp;
curbuf = wp->w_buffer;
+ current_sctx = wp->w_p_script_ctx[WV_FDT];
- ++emsg_silent; // handle exceptions, but don't display errors
+ ++emsg_off; // handle exceptions, but don't display errors
text = eval_to_string_safe(wp->w_p_fdt,
- was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
- --emsg_silent;
+ was_set_insecurely((char_u *)"foldtext", OPT_LOCAL), TRUE);
+ --emsg_off;
if (text == NULL || did_emsg)
got_fdt_error = TRUE;
curwin = save_curwin;
curbuf = curwin->w_buffer;
+ current_sctx = saved_sctx;
}
last_lnum = lnum;
last_wp = wp;