Mirror of the Vim source from https://github.com/vim/vim
Revision | ebe56a24acb6e9b04c74bd390f7e5ba305a7d713 (tree) |
---|---|
Zeit | 2022-01-22 22:45:02 |
Autor | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
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
@@ -4162,7 +4162,7 @@ | ||
4162 | 4162 | tv.vval.v_number = wp->w_id; |
4163 | 4163 | set_var((char_u *)"g:statusline_winid", &tv, FALSE); |
4164 | 4164 | |
4165 | - usefmt = eval_to_string_safe(fmt + 2, use_sandbox); | |
4165 | + usefmt = eval_to_string_safe(fmt + 2, use_sandbox, FALSE); | |
4166 | 4166 | if (usefmt == NULL) |
4167 | 4167 | usefmt = fmt; |
4168 | 4168 |
@@ -4546,7 +4546,7 @@ | ||
4546 | 4546 | if (curwin != save_curwin) |
4547 | 4547 | VIsual_active = FALSE; |
4548 | 4548 | |
4549 | - str = eval_to_string_safe(p, use_sandbox); | |
4549 | + str = eval_to_string_safe(p, use_sandbox, FALSE); | |
4550 | 4550 | |
4551 | 4551 | curwin = save_curwin; |
4552 | 4552 | curbuf = save_curbuf; |
@@ -555,14 +555,16 @@ | ||
555 | 555 | char_u * |
556 | 556 | eval_to_string_safe( |
557 | 557 | char_u *arg, |
558 | - int use_sandbox) | |
558 | + int use_sandbox, | |
559 | + int keep_script_version) | |
559 | 560 | { |
560 | 561 | char_u *retval; |
561 | 562 | funccal_entry_T funccal_entry; |
562 | 563 | int save_sc_version = current_sctx.sc_version; |
563 | 564 | int save_garbage = may_garbage_collect; |
564 | 565 | |
565 | - current_sctx.sc_version = 1; | |
566 | + if (!keep_script_version) | |
567 | + current_sctx.sc_version = 1; | |
566 | 568 | save_funccal(&funccal_entry); |
567 | 569 | if (use_sandbox) |
568 | 570 | ++sandbox; |
@@ -2097,7 +2097,7 @@ | ||
2097 | 2097 | |
2098 | 2098 | set_vim_var_string(VV_FNAME, ptr, len); |
2099 | 2099 | res = eval_to_string_safe(curbuf->b_p_inex, |
2100 | - was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL)); | |
2100 | + was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL), FALSE); | |
2101 | 2101 | set_vim_var_string(VV_FNAME, NULL, 0); |
2102 | 2102 | return res; |
2103 | 2103 | } |
@@ -1923,7 +1923,6 @@ | ||
1923 | 1923 | if (*wp->w_p_fdt != NUL) |
1924 | 1924 | { |
1925 | 1925 | char_u dashes[MAX_LEVEL + 2]; |
1926 | - win_T *save_curwin; | |
1927 | 1926 | int level; |
1928 | 1927 | char_u *p; |
1929 | 1928 |
@@ -1941,23 +1940,27 @@ | ||
1941 | 1940 | set_vim_var_string(VV_FOLDDASHES, dashes, -1); |
1942 | 1941 | set_vim_var_nr(VV_FOLDLEVEL, (long)level); |
1943 | 1942 | |
1944 | - // skip evaluating foldtext on errors | |
1943 | + // skip evaluating 'foldtext' on errors | |
1945 | 1944 | if (!got_fdt_error) |
1946 | 1945 | { |
1947 | - save_curwin = curwin; | |
1946 | + win_T *save_curwin = curwin; | |
1947 | + sctx_T saved_sctx = current_sctx; | |
1948 | + | |
1948 | 1949 | curwin = wp; |
1949 | 1950 | curbuf = wp->w_buffer; |
1950 | - | |
1951 | - ++emsg_silent; // handle exceptions, but don't display errors | |
1951 | + current_sctx = wp->w_p_script_ctx[WV_FDT]; | |
1952 | + | |
1953 | + ++emsg_off; // handle exceptions, but don't display errors | |
1952 | 1954 | text = eval_to_string_safe(wp->w_p_fdt, |
1953 | - was_set_insecurely((char_u *)"foldtext", OPT_LOCAL)); | |
1954 | - --emsg_silent; | |
1955 | + was_set_insecurely((char_u *)"foldtext", OPT_LOCAL), TRUE); | |
1956 | + --emsg_off; | |
1955 | 1957 | |
1956 | 1958 | if (text == NULL || did_emsg) |
1957 | 1959 | got_fdt_error = TRUE; |
1958 | 1960 | |
1959 | 1961 | curwin = save_curwin; |
1960 | 1962 | curbuf = curwin->w_buffer; |
1963 | + current_sctx = saved_sctx; | |
1961 | 1964 | } |
1962 | 1965 | last_lnum = lnum; |
1963 | 1966 | last_wp = wp; |
@@ -14,7 +14,7 @@ | ||
14 | 14 | char_u *typval2string(typval_T *tv, int convert); |
15 | 15 | char_u *eval_to_string_eap(char_u *arg, int convert, exarg_T *eap); |
16 | 16 | char_u *eval_to_string(char_u *arg, int convert); |
17 | -char_u *eval_to_string_safe(char_u *arg, int use_sandbox); | |
17 | +char_u *eval_to_string_safe(char_u *arg, int use_sandbox, int keep_script_version); | |
18 | 18 | varnumber_T eval_to_number(char_u *expr); |
19 | 19 | typval_T *eval_expr(char_u *arg, exarg_T *eap); |
20 | 20 | int call_vim_function(char_u *func, int argc, typval_T *argv, typval_T *rettv); |
@@ -683,6 +683,9 @@ | ||
683 | 683 | export def Expr(): string |
684 | 684 | return getline(v:lnum) =~ '^#' ? '>1' : '1' |
685 | 685 | enddef |
686 | + export def Text(): string | |
687 | + return 'fold text' | |
688 | + enddef | |
686 | 689 | g:fold_loaded = 'yes' |
687 | 690 | END |
688 | 691 | writefile(lines, 'Xdir/autoload/fold.vim') |
@@ -691,6 +694,7 @@ | ||
691 | 694 | vim9script |
692 | 695 | import autoload 'fold.vim' |
693 | 696 | &foldexpr = 'fold.Expr()' |
697 | + &foldtext = 'fold.Text()' | |
694 | 698 | &foldmethod = 'expr' |
695 | 699 | &debug = 'throw' |
696 | 700 | END |
@@ -706,7 +710,7 @@ | ||
706 | 710 | edit! otherfile |
707 | 711 | redraw |
708 | 712 | |
709 | - set foldexpr= foldmethod& debug= | |
713 | + set foldexpr= foldtext& foldmethod& debug= | |
710 | 714 | bwipe! |
711 | 715 | delete('Xdir', 'rf') |
712 | 716 | &rtp = save_rtp |
@@ -751,6 +751,8 @@ | ||
751 | 751 | static int included_patches[] = |
752 | 752 | { /* Add new patch number below this line */ |
753 | 753 | /**/ |
754 | + 4179, | |
755 | +/**/ | |
754 | 756 | 4178, |
755 | 757 | /**/ |
756 | 758 | 4177, |