]> granicus.if.org Git - neomutt/commitdiff
fix trash mailbox
authorRichard Russon <rich@flatcap.org>
Sun, 10 Jun 2018 14:25:48 +0000 (15:25 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 11 Jun 2018 10:04:57 +0000 (11:04 +0100)
The second `for` loop was using the value of `i` as a starting place.
By changing the first loop, the second loop wasn't doing any work.

Fixes #1253

mx.c

diff --git a/mx.c b/mx.c
index 33a8a8297e7569b7bb3be33ac613ec0fcfd1bb8e..b453c66a4b9bec6540ad85e5f598bdad4852e35f 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -617,10 +617,18 @@ static int trash_append(struct Context *ctx)
     return 0;
 
   int delmsgcount = 0;
+  int first_del = -1;
   for (i = 0; i < ctx->msgcount; i++)
+  {
     if (ctx->hdrs[i]->deleted && (!ctx->hdrs[i]->purge))
+    {
+      if (first_del < 0)
+        first_del = i;
       delmsgcount++;
-  if (i == ctx->msgcount)
+    }
+  }
+
+  if (delmsgcount == 0)
     return 0; /* nothing to be done */
 
   /* avoid the "append messages" prompt */
@@ -632,7 +640,7 @@ static int trash_append(struct Context *ctx)
     Confirmappend = true;
   if (rc != 0)
   {
-    /* L10N: Although we now the precise number of messages, we do not show it to the user.
+    /* L10N: Although we know the precise number of messages, we do not show it to the user.
        So feel free to use a "generic plural" as plural translation if your language has one.
      */
     mutt_error(ngettext("message not deleted", "messages not deleted", delmsgcount));
@@ -656,7 +664,7 @@ static int trash_append(struct Context *ctx)
   if (mx_mbox_open(Trash, MUTT_APPEND, &ctx_trash) != NULL)
   {
     /* continue from initial scan above */
-    for (; i < ctx->msgcount; i++)
+    for (i = first_del; i < ctx->msgcount; i++)
     {
       if (ctx->hdrs[i]->deleted && (!ctx->hdrs[i]->purge))
       {