]> granicus.if.org Git - neomutt/commitdiff
Add message padding to ctx->vsize computation
authorKevin McCarthy <kevin@8t8.us>
Thu, 26 Jul 2018 01:16:34 +0000 (18:16 -0700)
committerRichard Russon <rich@flatcap.org>
Sat, 1 Sep 2018 17:06:08 +0000 (18:06 +0100)
Use the mx_msg_padding_size() from the previous commit to be more
precise about the correct vsize.

This avoids strange situations where all the message are displayed in
a limit, but the vsize is not equal to the size.

compress.c
curs_main.c
mutt_thread.c
mx.c
pattern.c

index b01041d3031d251a29f763cd7e049b69c9d5acda..02e8cce71be699d414c4637356e65974801bd109 100644 (file)
@@ -904,7 +904,7 @@ static int comp_msg_padding_size(struct Context *ctx)
   if (!ci)
     return 0;
 
-  struct MxOps *ops = ci->child_ops;
+  const struct MxOps *ops = ci->child_ops;
   if (!ops || !ops->msg_padding_size)
     return 0;
 
index 90edd44d184580258bf1d7434de564bed1210f0c..39e4af24a405866fb7f00aaf8be6136131d25fd5 100644 (file)
@@ -455,6 +455,7 @@ static void update_index_unthreaded(struct Context *ctx, int check, int oldcount
    * they will be visible in the limited view */
   if (ctx->pattern)
   {
+    int padding = mx_msg_padding_size(ctx);
     for (int i = (check == MUTT_REOPENED) ? 0 : oldcount; i < ctx->msgcount; i++)
     {
       if (!i)
@@ -472,7 +473,7 @@ static void update_index_unthreaded(struct Context *ctx, int check, int oldcount
         ctx->hdrs[i]->limited = true;
         ctx->vcount++;
         struct Body *b = ctx->hdrs[i]->content;
-        ctx->vsize += b->length + b->offset - b->hdr_offset;
+        ctx->vsize += b->length + b->offset - b->hdr_offset + padding;
       }
     }
   }
index a3dc521886829e5cfa78aa752556ce56ac55bae5..e83012488b851e7990ff2df0b93e41a4113d8cdf 100644 (file)
@@ -33,6 +33,7 @@
 #include "mutt_thread.h"
 #include "context.h"
 #include "curs_lib.h"
+#include "mx.h"
 #include "protos.h"
 #include "sort.h"
 
@@ -1153,6 +1154,7 @@ void mutt_set_virtual(struct Context *ctx)
 
   ctx->vcount = 0;
   ctx->vsize = 0;
+  int padding = mx_msg_padding_size(ctx);
 
   for (int i = 0; i < ctx->msgcount; i++)
   {
@@ -1162,7 +1164,8 @@ void mutt_set_virtual(struct Context *ctx)
       cur->virtual = ctx->vcount;
       ctx->v2r[ctx->vcount] = i;
       ctx->vcount++;
-      ctx->vsize += cur->content->length + cur->content->offset - cur->content->hdr_offset;
+      ctx->vsize += cur->content->length + cur->content->offset -
+                    cur->content->hdr_offset + padding;
       cur->num_hidden = mutt_get_hidden(ctx, cur);
     }
   }
diff --git a/mx.c b/mx.c
index 214ea29e75440727f8ccc43445a95c699d92a02b..4d3330f35ffa34325e4dab830cb9dcb1fe2de28e 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -775,7 +775,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
  */
 void mx_update_tables(struct Context *ctx, bool committing)
 {
-  int i, j;
+  int i, j, padding;
 
   /* update memory to reflect the new state of the mailbox */
   ctx->vcount = 0;
@@ -786,6 +786,7 @@ void mx_update_tables(struct Context *ctx, bool committing)
   ctx->unread = 0;
   ctx->changed = false;
   ctx->flagged = 0;
+  padding = mx_msg_padding_size(ctx);
   for (i = 0, j = 0; i < ctx->msgcount; i++)
   {
     if (!ctx->hdrs[i]->quasi_deleted &&
@@ -803,7 +804,7 @@ void mx_update_tables(struct Context *ctx, bool committing)
         ctx->v2r[ctx->vcount] = j;
         ctx->hdrs[j]->virtual = ctx->vcount++;
         struct Body *b = ctx->hdrs[j]->content;
-        ctx->vsize += b->length + b->offset - b->hdr_offset;
+        ctx->vsize += b->length + b->offset - b->hdr_offset + padding;
       }
 
       if (committing)
index 7d3860c0d1951b76aa6d69201a8860c9496e7752..249809fc18edccbd39da4c10f6f4f20c6ea02b1b 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -2217,7 +2217,7 @@ int mutt_pattern_func(int op, char *prompt)
   struct Pattern *pat = NULL;
   char buf[LONG_STRING] = "", *simple = NULL;
   struct Buffer err;
-  int rc = -1;
+  int rc = -1, padding;
   struct Progress progress;
 
   mutt_str_strfcpy(buf, Context->pattern, sizeof(buf));
@@ -2254,6 +2254,7 @@ int mutt_pattern_func(int op, char *prompt)
     Context->vcount = 0;
     Context->vsize = 0;
     Context->collapsed = false;
+    padding = mx_msg_padding_size(Context);
 
     for (int i = 0; i < Context->msgcount; i++)
     {
@@ -2270,7 +2271,7 @@ int mutt_pattern_func(int op, char *prompt)
         Context->v2r[Context->vcount] = i;
         Context->vcount++;
         struct Body *b = Context->hdrs[i]->content;
-        Context->vsize += b->length + b->offset - b->hdr_offset;
+        Context->vsize += b->length + b->offset - b->hdr_offset + padding;
       }
     }
   }