mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 16:28:17 +00:00
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)
65ed136844
This commit is contained in:
@@ -3361,7 +3361,6 @@ int build_stl_str_hl(
|
|||||||
char_u *usefmt = fmt;
|
char_u *usefmt = fmt;
|
||||||
const int save_must_redraw = must_redraw;
|
const int save_must_redraw = must_redraw;
|
||||||
const int save_redr_type = curwin->w_redr_type;
|
const int save_redr_type = curwin->w_redr_type;
|
||||||
const int save_highlight_shcnaged = need_highlight_changed;
|
|
||||||
|
|
||||||
// When the format starts with "%!" then evaluate it as an expression and
|
// When the format starts with "%!" then evaluate it as an expression and
|
||||||
// use the result as the actual format string.
|
// use the result as the actual format string.
|
||||||
@@ -4425,12 +4424,12 @@ int build_stl_str_hl(
|
|||||||
cur_tab_rec->def.func = NULL;
|
cur_tab_rec->def.func = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We do not want redrawing a stausline, ruler, title, etc. to trigger
|
// When inside update_screen we do not want redrawing a stausline, ruler,
|
||||||
// another redraw, it may cause an endless loop. This happens when a
|
// title, etc. to trigger another redraw, it may cause an endless loop.
|
||||||
// statusline changes a highlight group.
|
if (updating_screen) {
|
||||||
must_redraw = save_must_redraw;
|
must_redraw = save_must_redraw;
|
||||||
curwin->w_redr_type = save_redr_type;
|
curwin->w_redr_type = save_redr_type;
|
||||||
need_highlight_changed = save_highlight_shcnaged;
|
}
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
@@ -6467,6 +6467,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
|
|||||||
int id;
|
int id;
|
||||||
int idx;
|
int idx;
|
||||||
struct hl_group item_before;
|
struct hl_group item_before;
|
||||||
|
bool did_change = false;
|
||||||
bool dodefault = false;
|
bool dodefault = false;
|
||||||
bool doclear = false;
|
bool doclear = false;
|
||||||
bool dolink = false;
|
bool dolink = false;
|
||||||
@@ -6839,6 +6840,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
|
|||||||
*namep = NULL;
|
*namep = NULL;
|
||||||
HL_TABLE()[idx].sg_rgb_fg = -1;
|
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;
|
*namep = NULL;
|
||||||
HL_TABLE()[idx].sg_rgb_bg = -1;
|
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;
|
*namep = NULL;
|
||||||
HL_TABLE()[idx].sg_rgb_sp = -1;
|
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
|
// Only call highlight_changed() once, after a sequence of highlight
|
||||||
// commands, and only if an attribute actually changed
|
// 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) {
|
&& !did_highlight_changed) {
|
||||||
|
// 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);
|
redraw_all_later(NOT_VALID);
|
||||||
|
}
|
||||||
need_highlight_changed = true;
|
need_highlight_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user