]> granicus.if.org Git - mutt/commitdiff
Fix menu color calls to occur before positioning the cursor. (see #3956)
authorKevin McCarthy <kevin@8t8.us>
Wed, 19 Jul 2017 21:04:32 +0000 (14:04 -0700)
committerKevin McCarthy <kevin@8t8.us>
Wed, 19 Jul 2017 21:04:32 +0000 (14:04 -0700)
It is possible for menu->color() to end up fetching an imap message,
and therefore generating a status message.

Because of this, we need to make those calls before we position the cursor.

menu.c

diff --git a/menu.c b/menu.c
index 3c45656b423595847e4046e3baf67a1c3ee06443..efda2399c8c7c56f11eb634d189c5e5bf3e69e11 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -292,15 +292,21 @@ void menu_redraw_index (MUTTMENU *menu)
 void menu_redraw_motion (MUTTMENU *menu)
 {
   char buf[LONG_STRING];
+  int old_color, cur_color;
 
   if (menu->dialog) 
   {
     menu->redraw &= ~REDRAW_MOTION;
     return;
   }
-  
+
+  /* Note: menu->color() for the index can end up retrieving a message
+   * over imap (if matching against ~h for instance).  This can
+   * generate status messages.  So we want to call it *before* we
+   * position the cursor for drawing. */
+  old_color = menu->color (menu->oldcurrent);
   mutt_window_move (menu->indexwin, menu->oldcurrent + menu->offset - menu->top, 0);
-  ATTRSET(menu->color (menu->oldcurrent));
+  ATTRSET(old_color);
 
   if (option (OPTARROWCURSOR))
   {
@@ -312,7 +318,7 @@ void menu_redraw_motion (MUTTMENU *menu)
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
       menu_pad_string (menu, buf, sizeof (buf));
       mutt_window_move (menu->indexwin, menu->oldcurrent + menu->offset - menu->top, 3);
-      print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+      print_enriched_string (old_color, (unsigned char *) buf, 1);
     }
 
     /* now draw it in the new location */
@@ -324,14 +330,15 @@ void menu_redraw_motion (MUTTMENU *menu)
     /* erase the current indicator */
     menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
     menu_pad_string (menu, buf, sizeof (buf));
-    print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+    print_enriched_string (old_color, (unsigned char *) buf, 1);
 
     /* now draw the new one to reflect the change */
+    cur_color = menu->color (menu->current);
     menu_make_entry (buf, sizeof (buf), menu, menu->current);
     menu_pad_string (menu, buf, sizeof (buf));
     SETCOLOR(MT_COLOR_INDICATOR);
     mutt_window_move (menu->indexwin, menu->current + menu->offset - menu->top, 0);
-    print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
+    print_enriched_string (cur_color, (unsigned char *) buf, 0);
   }
   menu->redraw &= REDRAW_STATUS;
   NORMAL_COLOR;