]> granicus.if.org Git - neomutt/commitdiff
Fix sidebar count updates when closing mailbox. (closes #3938)
authorKevin McCarthy <kevin@8t8.us>
Fri, 5 May 2017 01:05:06 +0000 (18:05 -0700)
committerKevin McCarthy <kevin@8t8.us>
Fri, 5 May 2017 01:05:06 +0000 (18:05 -0700)
The context unread and flagged counts were being updated too early in
mx_close_mailbox().  Cancelling at any of the following prompts would
leave them in an incorrect state.  Additionally, $move could increase
the delete count (for flagged messages), and $delete, if answered no,
could turn off message deletion.

Move all the sidebar buffy stat updating to the bottom of the
function, after all the prompts and processing.

mx.c

diff --git a/mx.c b/mx.c
index 21f38faeb7b211051083a9596caee77554431663..6cfed3726b67efa146f15d13647b8bfbba1ce217 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -801,12 +801,6 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
     if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read 
         && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
       read_msgs++;
-#ifdef USE_SIDEBAR
-    if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read)
-      ctx->unread--;
-    if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged)
-      ctx->flagged--;
-#endif
   }
 
   if (read_msgs && quadoption (OPT_MOVE) != MUTT_NO)
@@ -991,7 +985,17 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
     mx_unlink_empty (ctx->path);
 
 #ifdef USE_SIDEBAR
-  ctx->msgcount -= ctx->deleted;
+  if (purge && ctx->deleted)
+  {
+    for (i = 0; i < ctx->msgcount; i++)
+    {
+      if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read)
+        ctx->unread--;
+      if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged)
+        ctx->flagged--;
+    }
+    ctx->msgcount -= ctx->deleted;
+  }
   mutt_sb_set_buffystats (ctx);
 #endif