Skip to content

Commit ba2929b

Browse files
committed
patch 8.0.1073: may get an endless loop if 'statusline' changes a highlight
Problem: May get an endless loop if 'statusline' changes a highlight. Solution: Do not let evaluating 'statusline' trigger a redraw.
1 parent 9943329 commit ba2929b

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/buffer.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3915,8 +3915,8 @@ build_stl_str_hl(
39153915
char_u *t;
39163916
int byteval;
39173917
#ifdef FEAT_EVAL
3918-
win_T *o_curwin;
3919-
buf_T *o_curbuf;
3918+
win_T *save_curwin;
3919+
buf_T *save_curbuf;
39203920
#endif
39213921
int empty_line;
39223922
colnr_T virtcol;
@@ -3958,6 +3958,9 @@ build_stl_str_hl(
39583958
char_u tmp[TMPLEN];
39593959
char_u *usefmt = fmt;
39603960
struct stl_hlrec *sp;
3961+
int save_must_redraw = must_redraw;
3962+
int save_redr_type = curwin->w_redr_type;
3963+
int save_highlight_shcnaged = need_highlight_changed;
39613964

39623965
#ifdef FEAT_EVAL
39633966
/*
@@ -4267,15 +4270,15 @@ build_stl_str_hl(
42674270
vim_snprintf((char *)tmp, sizeof(tmp), "%d", curbuf->b_fnum);
42684271
set_internal_string_var((char_u *)"actual_curbuf", tmp);
42694272

4270-
o_curbuf = curbuf;
4271-
o_curwin = curwin;
4273+
save_curbuf = curbuf;
4274+
save_curwin = curwin;
42724275
curwin = wp;
42734276
curbuf = wp->w_buffer;
42744277

42754278
str = eval_to_string_safe(p, &t, use_sandbox);
42764279

4277-
curwin = o_curwin;
4278-
curbuf = o_curbuf;
4280+
curwin = save_curwin;
4281+
curbuf = save_curbuf;
42794282
do_unlet((char_u *)"g:actual_curbuf", TRUE);
42804283

42814284
if (str != NULL && *str != 0)
@@ -4730,6 +4733,13 @@ build_stl_str_hl(
47304733
sp->userhl = 0;
47314734
}
47324735

4736+
/* We do not want redrawing a stausline, ruler, title, etc. to trigger
4737+
* another redraw, it may cause an endless loop. This happens when a
4738+
* statusline changes a highlight group. */
4739+
must_redraw = save_must_redraw;
4740+
curwin->w_redr_type = save_redr_type;
4741+
need_highlight_changed = save_highlight_shcnaged;
4742+
47334743
return width;
47344744
}
47354745
#endif /* FEAT_STL_OPT */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
1073,
772774
/**/
773775
1072,
774776
/**/

0 commit comments

Comments
 (0)