From: Kevin McCarthy Date: Wed, 19 Jul 2017 21:04:32 +0000 (-0700) Subject: Fix menu color calls to occur before positioning the cursor. (see #3956) X-Git-Tag: mutt-1-9-1-rel~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4790f248dfc6ddb8553cb83c2c6ec95a82f92e44;p=mutt Fix menu color calls to occur before positioning the cursor. (see #3956) 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. --- diff --git a/menu.c b/menu.c index 3c45656b..efda2399 100644 --- 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;