mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
updated for version 7.3.1199
Problem: When evaluating 'foldexpr' causes an error this is silently ignored and evaluation is retried every time. Solution: Set emsg_silent instead of emsg_off. Stop evaluating 'foldexpr' is it is causing errors. (Christian Brabandt)
This commit is contained in:
33
src/fold.c
33
src/fold.c
@@ -1930,8 +1930,22 @@ get_foldtext(wp, lnum, lnume, foldinfo, buf)
|
|||||||
char_u *buf;
|
char_u *buf;
|
||||||
{
|
{
|
||||||
char_u *text = NULL;
|
char_u *text = NULL;
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
|
/* an error occurred when evaluating 'fdt' setting */
|
||||||
|
static int got_fdt_error = FALSE;
|
||||||
|
int save_did_emsg = did_emsg;
|
||||||
|
static win_T *last_wp = NULL;
|
||||||
|
static linenr_T last_lnum = 0;
|
||||||
|
|
||||||
|
if (last_wp != wp || last_wp == NULL
|
||||||
|
|| last_lnum > lnum || last_lnum == 0)
|
||||||
|
/* window changed, try evaluating foldtext setting once again */
|
||||||
|
got_fdt_error = FALSE;
|
||||||
|
|
||||||
|
if (!got_fdt_error)
|
||||||
|
/* a previous error should not abort evaluating 'foldexpr' */
|
||||||
|
did_emsg = FALSE;
|
||||||
|
|
||||||
if (*wp->w_p_fdt != NUL)
|
if (*wp->w_p_fdt != NUL)
|
||||||
{
|
{
|
||||||
char_u dashes[MAX_LEVEL + 2];
|
char_u dashes[MAX_LEVEL + 2];
|
||||||
@@ -1952,19 +1966,32 @@ get_foldtext(wp, lnum, lnume, foldinfo, buf)
|
|||||||
dashes[level] = NUL;
|
dashes[level] = NUL;
|
||||||
set_vim_var_string(VV_FOLDDASHES, dashes, -1);
|
set_vim_var_string(VV_FOLDDASHES, dashes, -1);
|
||||||
set_vim_var_nr(VV_FOLDLEVEL, (long)level);
|
set_vim_var_nr(VV_FOLDLEVEL, (long)level);
|
||||||
|
|
||||||
|
/* skip evaluating foldtext on errors */
|
||||||
|
if (!got_fdt_error)
|
||||||
|
{
|
||||||
save_curwin = curwin;
|
save_curwin = curwin;
|
||||||
curwin = wp;
|
curwin = wp;
|
||||||
curbuf = wp->w_buffer;
|
curbuf = wp->w_buffer;
|
||||||
|
|
||||||
++emsg_off;
|
++emsg_silent; /* handle exceptions, but don't display errors */
|
||||||
text = eval_to_string_safe(wp->w_p_fdt, NULL,
|
text = eval_to_string_safe(wp->w_p_fdt, NULL,
|
||||||
was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
|
was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
|
||||||
--emsg_off;
|
--emsg_silent;
|
||||||
|
|
||||||
|
if (text == NULL || did_emsg)
|
||||||
|
got_fdt_error = TRUE;
|
||||||
|
|
||||||
curwin = save_curwin;
|
curwin = save_curwin;
|
||||||
curbuf = curwin->w_buffer;
|
curbuf = curwin->w_buffer;
|
||||||
|
}
|
||||||
|
last_lnum = lnum;
|
||||||
|
last_wp = wp;
|
||||||
set_vim_var_string(VV_FOLDDASHES, NULL, -1);
|
set_vim_var_string(VV_FOLDDASHES, NULL, -1);
|
||||||
|
|
||||||
|
if (!did_emsg && save_did_emsg)
|
||||||
|
did_emsg = save_did_emsg;
|
||||||
|
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
/* Replace unprintable characters, if there are any. But
|
/* Replace unprintable characters, if there are any. But
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1199,
|
||||||
/**/
|
/**/
|
||||||
1198,
|
1198,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user