From 8c8961d9a28ad9c79dc8de09801d975b8a450257 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 28 Jun 2019 20:50:04 -0400 Subject: vim-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 vim/vim#2171, closes vim/vim#2120) https://github.com/vim/vim/commit/65ed136844fbaffdd473903ed841c944600234dc --- src/nvim/syntax.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/nvim/syntax.c') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index e3aa898bea..0d204b2f43 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6467,6 +6467,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) int id; int idx; struct hl_group item_before; + bool did_change = false; bool dodefault = false; bool doclear = false; bool dolink = false; @@ -6839,6 +6840,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) *namep = NULL; HL_TABLE()[idx].sg_rgb_fg = -1; } + did_change = true; } } @@ -6862,6 +6864,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) *namep = NULL; HL_TABLE()[idx].sg_rgb_bg = -1; } + did_change = true; } } @@ -6885,6 +6888,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) *namep = NULL; HL_TABLE()[idx].sg_rgb_sp = -1; } + did_change = true; } } @@ -6946,9 +6950,15 @@ void do_highlight(const char *line, const bool forceit, const bool init) // Only call highlight_changed() once, after a sequence of highlight // commands, and only if an attribute actually changed - if (memcmp(&HL_TABLE()[idx], &item_before, sizeof(item_before)) != 0 + if ((did_change + || memcmp(&HL_TABLE()[idx], &item_before, sizeof(item_before)) != 0) && !did_highlight_changed) { - redraw_all_later(NOT_VALID); + // Do not trigger a redraw when highlighting is changed while + // redrawing. This may happen when evaluating 'statusline' changes the + // StatusLine group. + if (!updating_screen) { + redraw_all_later(NOT_VALID); + } need_highlight_changed = true; } } -- cgit