summaryrefslogtreecommitdiffstats
path: root/flags.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-08-14 15:38:20 -0700
committerKevin McCarthy <kevin@8t8.us>2021-08-14 15:38:20 -0700
commitc9fa0414d19a30f2828910932b47d3e2bc3019d3 (patch)
treea99e43be90ca4b8e1df837d163197aa8278bacd9 /flags.c
parent5aa75ed2b8eac107d7acf5c58cd66bd0def213ae (diff)
Lazily update header colors after a thread-flag update.
Although there are other issues with threads and ~() color patterns, this helps with collapsed thread coloring. The thread-flag update can change the matching pattern, but that should be determined after all the thread messages are changed. For example, a collapsed thread with deleted messages and a color pattern '~v ~(~D)' should display differently after <undelete-thread>. Changing it to update colors lazily allows correct coloring (for that case).
Diffstat (limited to 'flags.c')
-rw-r--r--flags.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/flags.c b/flags.c
index 88cd03fc..5b016559 100644
--- a/flags.c
+++ b/flags.c
@@ -26,12 +26,14 @@
#include "sort.h"
#include "mx.h"
-void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
+void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_flags)
{
int changed = h->changed;
int deleted = ctx->deleted;
int tagged = ctx->tagged;
int flagged = ctx->flagged;
+ int upd_ctx = (upd_flags & MUTT_SET_FLAG_UPDATE_CONTEXT);
+ int upd_color = (upd_flags & MUTT_SET_FLAG_UPDATE_COLOR);
int update = 0;
if (ctx->readonly && flag != MUTT_TAG)
@@ -272,7 +274,13 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
if (update)
{
- mutt_set_header_color(ctx, h);
+ if (upd_color)
+ mutt_set_header_color (ctx, h);
+ else
+ {
+ h->color.pair = 0;
+ h->color.attrs = 0;
+ }
#ifdef USE_SIDEBAR
mutt_set_current_menu_redraw (REDRAW_SIDEBAR);
#endif
@@ -294,6 +302,7 @@ void mutt_tag_set_flag (int flag, int bf)
if (Context->hdrs[Context->v2r[j]]->tagged)
mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
}
+
int mutt_thread_set_flag (HEADER *hdr, int flag, int bf, int subthread)
{
THREAD *start, *cur = hdr->thread;
@@ -309,8 +318,17 @@ int mutt_thread_set_flag (HEADER *hdr, int flag, int bf, int subthread)
cur = cur->parent;
start = cur;
+ /* For thread flag setting, there are some corner cases that make it
+ * better to set the color values afterwards. For example coloring
+ * collapsed threads with a deleted message in them '~v ~(~D)', if
+ * we <undelete-thread> it's better to determine the color lazily in the
+ * index after all the flag settings for the thread is done.
+ */
if (cur->message)
- mutt_set_flag (Context, cur->message, flag, bf);
+ {
+ _mutt_set_flag (Context, cur->message, flag, bf, MUTT_SET_FLAG_UPDATE_CONTEXT);
+ cur->message->color.pair = cur->message->color.attrs = 0;
+ }
if ((cur = cur->child) == NULL)
return (0);
@@ -318,7 +336,10 @@ int mutt_thread_set_flag (HEADER *hdr, int flag, int bf, int subthread)
FOREVER
{
if (cur->message)
- mutt_set_flag (Context, cur->message, flag, bf);
+ {
+ _mutt_set_flag (Context, cur->message, flag, bf, MUTT_SET_FLAG_UPDATE_CONTEXT);
+ cur->message->color.pair = cur->message->color.attrs = 0;
+ }
if (cur->child)
cur = cur->child;