]> granicus.if.org Git - neomutt/commitdiff
Improve index color cache flushing behavior
authorKevin McCarthy <kevin@8t8.us>
Wed, 21 Feb 2018 03:09:16 +0000 (19:09 -0800)
committerRichard Russon <rich@flatcap.org>
Wed, 21 Feb 2018 03:09:16 +0000 (19:09 -0800)
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.

color.c

diff --git a/color.c b/color.c
index 6d57b7522e3caee834ac9e0b9e4d164f48cfb792..5e5a32231fe3105abd48f378b74f1e0a83e8ab4a 100644 (file)
--- a/color.c
+++ b/color.c
@@ -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 */
@@ -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
     {
@@ -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;
 }