struct maildir *md, *p;
struct maildir **last;
HASH *fnames;
- int i, j;
+ int i, idx;
if(!option (OPTCHECKNEW))
return 0;
hash_insert(fnames, p->canon_fname, p, 0);
}
+
+ if(index_hint) idx = *index_hint;
for(i = 0; i < ctx->msgcount; i++)
{
ctx->hdrs[i]->active = 0;
+
if(ctx->magic == M_MAILDIR)
maildir_canon_filename(b1, ctx->hdrs[i]->path, sizeof(b1));
else
strfcpy(b1, ctx->hdrs[i]->path, sizeof(b1));
- if((p = hash_find(fnames, b1)))
+ if((p = hash_find(fnames, b1)) && p->h &&
+ mbox_strict_cmp_headers(ctx->hdrs[i], p->h))
{
- if(!p->h)
- continue;
-
- if(!mbox_strict_cmp_headers(ctx->hdrs[i], p->h))
- continue;
-
+ /* found the right message */
+
if(modified)
{
if(!ctx->hdrs[i]->changed)
ctx->hdrs[i]->active = 1;
mutt_free_header(&p->h);
}
+ else
+ {
+ /* the message has disappeared by occult forces, correct
+ * the index hint.
+ */
+
+ if(index_hint && (i <= *index_hint))
+ idx--;
+ }
}
hash_destroy(&fnames, NULL);
mx_update_tables(ctx, 0);
maildir_move_to_context(ctx, &md);
+
+ if(index_hint)
+ *index_hint = idx;
+
return modified ? M_REOPENED : have_new ? M_NEW_MAIL : 0;
}