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.
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)
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