From: Kevin McCarthy Date: Thu, 26 Jul 2018 01:16:34 +0000 (-0700) Subject: Add message padding to ctx->vsize computation X-Git-Tag: 2019-10-25~671^2~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f641fca868d46aeb860e895b4eb6efc6a84d1937;p=neomutt 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/compress.c b/compress.c index b01041d30..02e8cce71 100644 --- a/compress.c +++ b/compress.c @@ -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; diff --git a/curs_main.c b/curs_main.c index 90edd44d1..39e4af24a 100644 --- a/curs_main.c +++ b/curs_main.c @@ -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; } } } diff --git a/mutt_thread.c b/mutt_thread.c index a3dc52188..e83012488 100644 --- a/mutt_thread.c +++ b/mutt_thread.c @@ -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 214ea29e7..4d3330f35 100644 --- 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) diff --git a/pattern.c b/pattern.c index 7d3860c0d..249809fc1 100644 --- 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; } } }