]> granicus.if.org Git - mutt/commitdiff
Improve index color cache flushing behavior.
authorKevin McCarthy <kevin@8t8.us>
Wed, 21 Feb 2018 03:09:16 +0000 (19:09 -0800)
committerKevin McCarthy <kevin@8t8.us>
Wed, 21 Feb 2018 03:43:19 +0000 (19:43 -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 df9cd4714b2d6c950878485d21ceb096eda474a9..48ca1f8d91c41a6d421b741152156c5a54c5ff6f 100644 (file)
--- a/color.c
+++ b/color.c
@@ -409,7 +409,7 @@ int mutt_parse_unmono (BUFFER *buf, BUFFER *s, unsigned long data,
 static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data,
                                BUFFER *err, short parse_uncolor)
 {
-  int object = 0, do_cache = 0;
+  int object = 0, is_index = 0, do_cache = 0;
   COLOR_LINE *tmp, *last = NULL;
   COLOR_LINE **list;
 
@@ -422,7 +422,10 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data,
   }
 
   if (mutt_strncmp (buf->data, "index", 5) == 0)
+  {
+    is_index = 1;
     list = &ColorIndexList;
+  }
   else if (mutt_strncmp (buf->data, "body", 4) == 0)
     list = &ColorBodyList;
   else if (mutt_strncmp (buf->data, "header", 7) == 0)
@@ -502,7 +505,7 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data,
   while (MoreArgs (s));
 
 
-  if (do_cache && !option (OPTNOCURSES))
+  if (is_index && do_cache && !option (OPTNOCURSES))
   {
     int i;
     mutt_set_menu_redraw_full (MENU_MAIN);
@@ -567,8 +570,6 @@ add_pattern (COLOR_LINE **top, const char *s, int sensitive,
     tmp = mutt_new_color_line ();
     if (is_index) 
     {
-      int i;
-
       strfcpy(buf, NONULL(s), sizeof(buf));
       mutt_check_simple (buf, sizeof (buf), NONULL(SimpleSearch));
       if((tmp->color_pattern = mutt_pattern_comp (buf, MUTT_FULL_MSG, err)) == NULL)
@@ -576,9 +577,6 @@ add_pattern (COLOR_LINE **top, const char *s, int sensitive,
        mutt_free_color_line(&tmp, 1);
        return -1;
       }
-      /* force re-caching of index colors */
-      for (i = 0; Context && i < Context->msgcount; i++)
-       Context->hdrs[i]->pair = 0;
     }
     else if ((r = REGCOMP (&tmp->rx, s, (sensitive ? mutt_which_case (s) : REG_ICASE))) != 0)
     {
@@ -600,6 +598,15 @@ add_pattern (COLOR_LINE **top, const char *s, int sensitive,
     *top = tmp;
   }
 
+  /* force re-caching of index colors */
+  if (is_index)
+  {
+    int i;
+
+    for (i = 0; Context && i < Context->msgcount; i++)
+      Context->hdrs[i]->pair = 0;
+  }
+
   return 0;
 }