From: Kevin McCarthy Date: Fri, 5 May 2017 01:05:06 +0000 (-0700) Subject: Fix sidebar count updates when closing mailbox. (closes #3938) X-Git-Tag: neomutt-20170602^2^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25f7be23aadbdadf00be28dd9a4057b7fc279204;p=neomutt Fix sidebar count updates when closing mailbox. (closes #3938) 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. --- diff --git a/mx.c b/mx.c index 21f38faeb..6cfed3726 100644 --- 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