]> granicus.if.org Git - mutt/commitdiff
Don't lose track of the current message when collapsing and changing
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 3 Sep 2001 13:59:37 +0000 (13:59 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 3 Sep 2001 13:59:37 +0000 (13:59 +0000)
sort modes wildly.  Noted by David T-G.

curs_main.c
thread.c

index 8baefbc2cbae8321df24a0862e479ac83a7dc8d2..07b82cbf6ac09bbc547e509de57edad44a273d01 100644 (file)
@@ -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;
 }
 
index a071e90ef57dbb6695310fb1ef73924ce0778328..a729baebfd8889f24dda1edef04b269ea9daf4c4 100644 (file)
--- a/thread.c
+++ b/thread.c
@@ -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");