]> granicus.if.org Git - neomutt/commitdiff
Fixing more maildir cursor problems.
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 6 May 1999 08:29:17 +0000 (08:29 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 6 May 1999 08:29:17 +0000 (08:29 +0000)
curs_main.c
flags.c
mh.c

index 2d0bd16942959a57daccc8337250117fa524b3a3..2a96707dcda6cde494f7e03832d350c6a2d42837 100644 (file)
@@ -957,7 +957,7 @@ int mutt_index_menu (void)
        }
 
        menu->menu = MENU_PAGER;
-       menu->oldcurrent = menu->current;
+/*     menu->oldcurrent = menu->current;  */
        continue;
 
       case OP_EXIT:
diff --git a/flags.c b/flags.c
index c38d9a07c4868dcb7b857bf38394653d6f1fe6ec..71505afe1f5c746c758efef05b03862782f10a9a 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -47,7 +47,7 @@ void mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf)
        ctx->deleted--;
 #ifdef USE_IMAP
 /* if you undelete a message, the imap server will probably need to know. */
-       if(ctx->magic==M_IMAP) 
+       if (ctx->magic == M_IMAP) 
        {
          h->changed = 1;
          ctx->changed = 1;
diff --git a/mh.c b/mh.c
index 15beddba277d025581f9f5427519722b9e1a6951..5b398b5012812178631cf9e5651340731116e890 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -530,7 +530,7 @@ static int maildir_sync_message (CONTEXT *ctx, int msgno)
 int mh_sync_mailbox (CONTEXT * ctx)
 {
   char path[_POSIX_PATH_MAX], tmp[_POSIX_PATH_MAX];
-  int i, rc = 0;
+  int i, j, rc = 0;
   
   i = mh_check_mailbox(ctx, NULL);
 
@@ -569,12 +569,27 @@ int mh_sync_mailbox (CONTEXT * ctx)
        maildir_sync_message (ctx, i);
       else
       {
-       /* FOO - seems ok to ignore errors, but might want to warn... */
+       /* XXX - seems ok to ignore errors, but might want to warn... */
        mh_sync_message (ctx, i);
       }
     }
   }
+
+  /* XXX race condition? */
+
   maildir_update_mtime(ctx);
+
+  /* adjust indices */
+
+  if (ctx->deleted)
+  {
+    for (i = 0, j = 0; i < ctx->msgcount; i++)
+    {
+      if (!ctx->hdrs[i]->deleted)
+       ctx->hdrs[i]->index = j++;
+    }
+  }
+
   return (rc);
 }
 
@@ -612,7 +627,7 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
   struct maildir *md, *p;
   struct maildir **last;
   HASH *fnames;
-  int i, deleted;
+  int i, j, deleted;
   
   if(!option (OPTCHECKNEW))
     return 0;
@@ -777,22 +792,39 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
       
       occult = 1;
 
-      if(index_hint && (i < *index_hint))
-       deleted++;
     }
   }
 
-  if (index_hint && occult)
-    *index_hint -= deleted;
-  
-  /* dump the file name hash */
+  /* destroy the file name hash */
 
   hash_destroy(&fnames, NULL);
 
   /* If we didn't just get new mail, update the tables. */
   
   if(modified || occult)
+  {
+    short old_sort;
+    int old_count;
+
+    if (Sort != SORT_ORDER)
+    {
+      old_sort = Sort;
+      Sort = SORT_ORDER;
+      mutt_sort_headers (ctx, 1);
+      Sort = old_sort;
+    }
+  
+    old_count = ctx->msgcount;
+    for (i = 0, j = 0; i < old_count; i++)
+    {
+      if (ctx->hdrs[i]->active && index_hint && *index_hint == i)
+       *index_hint = j;
+
+      if (ctx->hdrs[i]->active)
+       ctx->hdrs[i]->index = j++;
+    }
     mx_update_tables(ctx, 0);
+  }
 
   /* Incorporate new messages */