Skip to content

Commit

Permalink
Improve index color cache flushing behavior
Browse files Browse the repository at this point in the history
Flush when redefining the colors for an existing color line, in
addition to when defining a new color line.

Flush only when uncoloring the index.
  • Loading branch information
kevin8t8 authored and flatcap committed Feb 21, 2018
1 parent 23c7629 commit f85bd42
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions color.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,11 @@ static int parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long dat
else if (object == MT_COLOR_INDEX_TAG)
do_uncolor(buf, s, &ColorIndexTagList, &do_cache, parse_uncolor);

if (do_cache && !OPT_NO_CURSES)
bool is_index = ((object == MT_COLOR_INDEX) || (object == MT_COLOR_INDEX_AUTHOR) ||
(object == MT_COLOR_INDEX_FLAGS) || (object == MT_COLOR_INDEX_SUBJECT) ||
(object == MT_COLOR_INDEX_TAG));

if (is_index && do_cache && !OPT_NO_CURSES)
{
mutt_set_menu_redraw_full(MENU_MAIN);
/* force re-caching of index colors */
Expand Down Expand Up @@ -655,9 +659,6 @@ static int add_pattern(struct ColorLineHead *top, const char *s, int sensitive,
free_color_line(tmp, 1);
return -1;
}
/* force re-caching of index colors */
for (int i = 0; Context && i < Context->msgcount; i++)
Context->hdrs[i]->pair = 0;
}
else
{
Expand Down Expand Up @@ -689,6 +690,13 @@ static int add_pattern(struct ColorLineHead *top, const char *s, int sensitive,
STAILQ_INSERT_HEAD(top, tmp, entries);
}

/* force re-caching of index colors */
if (is_index)
{
for (int i = 0; Context && i < Context->msgcount; i++)
Context->hdrs[i]->pair = 0;
}

return 0;
}

Expand Down

0 comments on commit f85bd42

Please sign in to comment.