aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fold.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-17 15:09:05 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-17 15:46:24 +0800
commitd6e0f3dad2176b2619ea3ca2a8f622c00d4f78af (patch)
tree5cdfc23d3693ed77a4b1c80d461e0e804ee2d6b7 /src/nvim/fold.c
parent0dbb0419f47a76441d1e937d728033694c41cde7 (diff)
downloadrneovim-d6e0f3dad2176b2619ea3ca2a8f622c00d4f78af.tar.gz
rneovim-d6e0f3dad2176b2619ea3ca2a8f622c00d4f78af.tar.bz2
rneovim-d6e0f3dad2176b2619ea3ca2a8f622c00d4f78af.zip
vim-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. https://github.com/vim/vim/commit/9530b580a7b71960dbbdb2b12a3aafeb540bd135 Script version is N/A. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/fold.c')
-rw-r--r--src/nvim/fold.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index a0869b54c9..2066da280a 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -1742,16 +1742,19 @@ char *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldinfo
set_vim_var_string(VV_FOLDDASHES, dashes, -1);
set_vim_var_nr(VV_FOLDLEVEL, (varnumber_T)level);
- // skip evaluating foldtext on errors
+ // skip evaluating 'foldtext' on errors
if (!got_fdt_error) {
- win_T *save_curwin = curwin;
+ win_T *const save_curwin = curwin;
+ const sctx_T saved_sctx = current_sctx;
+
curwin = wp;
curbuf = wp->w_buffer;
+ current_sctx = wp->w_p_script_ctx[WV_FDT].script_ctx;
- 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(wp, "foldtext", OPT_LOCAL));
- emsg_silent--;
+ emsg_off--;
if (text == NULL || did_emsg) {
got_fdt_error = true;
@@ -1759,6 +1762,7 @@ char *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldinfo
curwin = save_curwin;
curbuf = curwin->w_buffer;
+ current_sctx = saved_sctx;
}
last_lnum = lnum;
last_wp = wp;