From: Kevin McCarthy Date: Thu, 26 Jul 2018 01:16:34 +0000 (-0700) Subject: Add message padding to ctx->vsize computation. X-Git-Tag: mutt-1-11-rel~106 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f5dc70f41a1510dad47b5d1500781b5fb0b9340;p=mutt Add message padding to ctx->vsize computation. 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. --- diff --git a/curs_main.c b/curs_main.c index 99338671..18493bb7 100644 --- a/curs_main.c +++ b/curs_main.c @@ -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 c5d86fc5..0dfd1970 100644 --- 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) diff --git a/pattern.c b/pattern.c index c8bb1859..bfb38c86 100644 --- 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; } } } diff --git a/thread.c b/thread.c index 2fb56fd5..308f2b4d 100644 --- a/thread.c +++ b/thread.c @@ -22,6 +22,7 @@ #include "mutt.h" #include "sort.h" +#include "mailbox.h" #include #include @@ -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); } }