]> granicus.if.org Git - mutt/commitdiff
Add message padding to ctx->vsize computation.
authorKevin McCarthy <kevin@8t8.us>
Thu, 26 Jul 2018 01:16:34 +0000 (18:16 -0700)
committerKevin McCarthy <kevin@8t8.us>
Thu, 26 Jul 2018 01:21:40 +0000 (18:21 -0700)
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.

curs_main.c
mx.c
pattern.c
thread.c

index 99338671bbdd411db351542eb29b835db625fdad..18493bb7c56c1b3d567db3a92c16b151a5b31013 100644 (file)
@@ -427,13 +427,14 @@ static void update_index_threaded (CONTEXT *ctx, int check, int oldcount)
 
 static void update_index_unthreaded (CONTEXT *ctx, int check, int oldcount)
 {
-  int j;
+  int j, padding;
 
   /* We are in a limited view. Check if the new message(s) satisfy
    * the limit criteria. If they do, set their virtual msgno so that
    * they will be visible in the limited view */
   if (ctx->pattern)
   {
+    padding = mx_msg_padding_size (ctx);
     for (j = (check == MUTT_REOPENED) ? 0 : oldcount; j < ctx->msgcount; j++)
     {
       if (!j)
@@ -453,7 +454,8 @@ static void update_index_unthreaded (CONTEXT *ctx, int check, int oldcount)
        ctx->v2r[ctx->vcount] = j;
        ctx->hdrs[j]->limited = 1;
        ctx->vcount++;
-       ctx->vsize += this_body->length + this_body->offset - this_body->hdr_offset;
+       ctx->vsize += this_body->length + this_body->offset -
+                      this_body->hdr_offset + padding;
       }
     }
   }
diff --git a/mx.c b/mx.c
index c5d86fc590b1e5c955d2163390fbcb76a3e70781..0dfd1970a066331145ae354a8f6936735ccc421f 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1042,7 +1042,7 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
 
 void mx_update_tables(CONTEXT *ctx, int committing)
 {
-  int i, j;
+  int i, j, padding;
   
   /* update memory to reflect the new state of the mailbox */
   ctx->vcount = 0;
@@ -1053,6 +1053,7 @@ void mx_update_tables(CONTEXT *ctx, int committing)
   ctx->unread = 0;
   ctx->changed = 0;
   ctx->flagged = 0;
+  padding = mx_msg_padding_size (ctx);
 #define this_body ctx->hdrs[j]->content
   for (i = 0, j = 0; i < ctx->msgcount; i++)
   {
@@ -1071,7 +1072,7 @@ void mx_update_tables(CONTEXT *ctx, int committing)
        ctx->v2r[ctx->vcount] = j;
        ctx->hdrs[j]->virtual = ctx->vcount++;
        ctx->vsize += this_body->length + this_body->offset -
-         this_body->hdr_offset;
+                     this_body->hdr_offset + padding;
       }
 
       if (committing)
index c8bb185904e2282c0da04bd3e75b287de67b0fd4..bfb38c86959e1660e9e8e61a20622e2af9c94291 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1445,7 +1445,7 @@ int mutt_pattern_func (int op, char *prompt)
   pattern_t *pat = NULL;
   char buf[LONG_STRING] = "", *simple = NULL;
   BUFFER err;
-  int i, rv = -1;
+  int i, rv = -1, padding;
   progress_t progress;
 
   strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
@@ -1480,6 +1480,7 @@ int mutt_pattern_func (int op, char *prompt)
     Context->vcount    = 0;
     Context->vsize     = 0;
     Context->collapsed = 0;
+    padding = mx_msg_padding_size (Context);
 
     for (i = 0; i < Context->msgcount; i++)
     {
@@ -1498,7 +1499,7 @@ int mutt_pattern_func (int op, char *prompt)
        Context->v2r[Context->vcount] = i;
        Context->vcount++;
        Context->vsize += this_body->length + this_body->offset -
-         this_body->hdr_offset;
+                         this_body->hdr_offset + padding;
       }
     }
   }
index 2fb56fd50a3e435e6e706989efbfa1e53ec92aba..308f2b4d957d80ff527454b2808a7a1630452880 100644 (file)
--- a/thread.c
+++ b/thread.c
@@ -22,6 +22,7 @@
 
 #include "mutt.h"
 #include "sort.h"
+#include "mailbox.h"
 
 #include <string.h>
 #include <ctype.h>
@@ -1114,11 +1115,12 @@ int mutt_parent_message (CONTEXT *ctx, HEADER *hdr, int find_root)
 
 void mutt_set_virtual (CONTEXT *ctx)
 {
-  int i;
+  int i, padding;
   HEADER *cur;
 
   ctx->vcount = 0;
   ctx->vsize = 0;
+  padding = mx_msg_padding_size (ctx);
 
   for (i = 0; i < ctx->msgcount; i++)
   {
@@ -1128,7 +1130,8 @@ void mutt_set_virtual (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);
     }
   }