Commit 5f5dc70f authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

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.
parent 9806d249
Pipeline #26520759 passed with stages
in 14 minutes and 18 seconds
......@@ -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;
}
}
}
......
......@@ -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)
......
......@@ -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;
}
}
}
......
......@@ -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);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment