Skip to content

Commit 65ed136

Browse files
committed
patch 8.0.1164: changing StatusLine highlight does not always work
Problem: Changing StatusLine highlight while evaluating 'statusline' may not change the status line color. Solution: When changing highlighting while redrawing don't cause another redraw. (suggested by Ozaki Kiichi, closes #2171, closes #2120)
1 parent c79977a commit 65ed136

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

src/buffer.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3910,7 +3910,6 @@ build_stl_str_hl(
39103910
struct stl_hlrec *sp;
39113911
int save_must_redraw = must_redraw;
39123912
int save_redr_type = curwin->w_redr_type;
3913-
int save_highlight_shcnaged = need_highlight_changed;
39143913

39153914
#ifdef FEAT_EVAL
39163915
/*
@@ -4683,12 +4682,13 @@ build_stl_str_hl(
46834682
sp->userhl = 0;
46844683
}
46854684

4686-
/* We do not want redrawing a stausline, ruler, title, etc. to trigger
4687-
* another redraw, it may cause an endless loop. This happens when a
4688-
* statusline changes a highlight group. */
4689-
must_redraw = save_must_redraw;
4690-
curwin->w_redr_type = save_redr_type;
4691-
need_highlight_changed = save_highlight_shcnaged;
4685+
/* When inside update_screen we do not want redrawing a stausline, ruler,
4686+
* title, etc. to trigger another redraw, it may cause an endless loop. */
4687+
if (updating_screen)
4688+
{
4689+
must_redraw = save_must_redraw;
4690+
curwin->w_redr_type = save_redr_type;
4691+
}
46924692

46934693
return width;
46944694
}

src/syntax.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7378,6 +7378,7 @@ do_highlight(
73787378
int id;
73797379
int idx;
73807380
struct hl_group item_before;
7381+
int did_change = FALSE;
73817382
int dodefault = FALSE;
73827383
int doclear = FALSE;
73837384
int dolink = FALSE;
@@ -7787,6 +7788,7 @@ do_highlight(
77877788
/* GUI not started yet, always accept the name. */
77887789
vim_free(HL_TABLE()[idx].sg_font_name);
77897790
HL_TABLE()[idx].sg_font_name = vim_strsave(arg);
7791+
did_change = TRUE;
77907792
}
77917793
else
77927794
{
@@ -7815,6 +7817,7 @@ do_highlight(
78157817
gui_mch_free_fontset(temp_sg_fontset);
78167818
vim_free(HL_TABLE()[idx].sg_font_name);
78177819
HL_TABLE()[idx].sg_font_name = vim_strsave(arg);
7820+
did_change = TRUE;
78187821
}
78197822
else
78207823
HL_TABLE()[idx].sg_fontset = temp_sg_fontset;
@@ -7826,6 +7829,7 @@ do_highlight(
78267829
gui_mch_free_font(temp_sg_font);
78277830
vim_free(HL_TABLE()[idx].sg_font_name);
78287831
HL_TABLE()[idx].sg_font_name = vim_strsave(arg);
7832+
did_change = TRUE;
78297833
}
78307834
else
78317835
HL_TABLE()[idx].sg_font = temp_sg_font;
@@ -7991,6 +7995,7 @@ do_highlight(
79917995
*namep = vim_strsave(arg);
79927996
else
79937997
*namep = NULL;
7998+
did_change = TRUE;
79947999
}
79958000
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
79968001
# ifdef FEAT_GUI_X11
@@ -8041,6 +8046,7 @@ do_highlight(
80418046
*namep = vim_strsave(arg);
80428047
else
80438048
*namep = NULL;
8049+
did_change = TRUE;
80448050
}
80458051
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
80468052
# ifdef FEAT_GUI_X11
@@ -8090,6 +8096,7 @@ do_highlight(
80908096
*namep = vim_strsave(arg);
80918097
else
80928098
*namep = NULL;
8099+
did_change = TRUE;
80938100
}
80948101
# ifdef FEAT_GUI
80958102
}
@@ -8259,13 +8266,18 @@ do_highlight(
82598266

82608267
/* Only call highlight_changed() once, after a sequence of highlight
82618268
* commands, and only if an attribute actually changed. */
8262-
if (memcmp(&HL_TABLE()[idx], &item_before, sizeof(item_before)) != 0
8269+
if ((did_change
8270+
|| memcmp(&HL_TABLE()[idx], &item_before, sizeof(item_before)) != 0)
82638271
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
82648272
&& !did_highlight_changed
82658273
#endif
82668274
)
82678275
{
8268-
redraw_all_later(NOT_VALID);
8276+
/* Do not trigger a redraw when highlighting is changed while
8277+
* redrawing. This may happen when evaluating 'statusline' changes the
8278+
* StatusLine group. */
8279+
if (!updating_screen)
8280+
redraw_all_later(NOT_VALID);
82698281
need_highlight_changed = TRUE;
82708282
}
82718283
}

src/version.c

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

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1164,
764766
/**/
765767
1163,
766768
/**/

0 commit comments

Comments
 (0)