Commit 76ecc91c authored by Thomas Roessler's avatar Thomas Roessler

Don't lose track of the current message when collapsing and changing

sort modes wildly.  Noted by David T-G.
parent eae3148e
......@@ -363,10 +363,12 @@ static void update_index (MUTTMENU *menu, CONTEXT *ctx, int check,
static void resort_index (MUTTMENU *menu)
{
int i;
const HEADER *current = CURHDR;
HEADER *current = CURHDR;
menu->current = -1;
mutt_sort_headers (Context, 0);
/* Restore the current message */
for (i = 0; i < Context->vcount; i++)
{
if (Context->hdrs[Context->v2r[i]] == current)
......@@ -375,6 +377,13 @@ static void resort_index (MUTTMENU *menu)
break;
}
}
if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0)
menu->current = mutt_parent_message (Context, current);
if (menu->current < 0)
menu->current = ci_first_message ();
menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
}
......
......@@ -756,7 +756,7 @@ int mutt_parent_message (CONTEXT *ctx, HEADER *hdr)
{
while ((hdr = hdr->parent))
{
if (!ctx->pattern || hdr->limited)
if (hdr->virtual >= 0 && hdr->collapsed && (!ctx->pattern || hdr->limited))
return (hdr->virtual);
}
mutt_error _("Parent message is not visible in limited view");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment