Mercurial > vim
diff src/fold.c @ 27301:ebe56a24acb6 v8.2.4179
patch 8.2.4179: 'foldtext' is evaluated in the current script context
Commit: https://github.com/vim/vim/commit/9530b580a7b71960dbbdb2b12a3aafeb540bd135
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 22 13:39:08 2022 +0000
patch 8.2.4179: 'foldtext' is evaluated in the current script context
Problem: 'foldtext' is evaluated in the current script context.
Solution: Use the script context where the option was set.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 22 Jan 2022 14:45:02 +0100 |
parents | e11682ba8c80 |
children | 41e0dcf38521 |
line wrap: on
line diff
--- 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; - - ++emsg_silent; // handle exceptions, but don't display errors + current_sctx = wp->w_p_script_ctx[WV_FDT]; + + ++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;