summaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-02-08 19:16:33 -0800
committerKevin McCarthy <kevin@8t8.us>2020-02-10 15:58:39 -0800
commit83be183b55a41b2ffb84177e8ce4e271fea67b00 (patch)
tree6f7c050dfc35c694d99a9a6cc13222afa8c31ad4 /thread.c
parent8d77022b4c94edbf197b11c07f0666bff0c1a08c (diff)
Fix ~v tagging when switching to non-threaded sorting.
Place num_hidden in all the collapsed thread messages, rather than just the visible ones (i.e. the root headers). This is a tweak to commit 0f8a079d, where I discovered the behavior inconsistent with the documentation. I'm making this change in master due to the (tiny) behavior change.
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/thread.c b/thread.c
index 9680108f..fc6c3cb8 100644
--- a/thread.c
+++ b/thread.c
@@ -1194,8 +1194,7 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *cur, int flag)
/* return value depends on action requested */
if (flag & (MUTT_THREAD_COLLAPSE | MUTT_THREAD_UNCOLLAPSE))
{
- if (roothdr)
- roothdr->num_hidden = num_hidden;
+ cur->num_hidden = num_hidden;
return (final);
}
else if (flag & MUTT_THREAD_UNREAD)
@@ -1279,13 +1278,45 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *cur, int flag)
}
}
+ /* retraverse the thread and store num_hidden in all headers, with
+ * or without a virtual index. this will allow ~v to match all
+ * collapsed messages when switching sort order to non-threaded.
+ */
+ if (flag & MUTT_THREAD_COLLAPSE)
+ {
+ thread = top;
+ FOREVER
+ {
+ cur = thread->message;
+ if (cur)
+ cur->num_hidden = num_hidden + 1;
+
+ if (thread->child)
+ thread = thread->child;
+ else if (thread->next)
+ thread = thread->next;
+ else
+ {
+ int done = 0;
+ while (!thread->next)
+ {
+ thread = thread->parent;
+ if (thread == top)
+ {
+ done = 1;
+ break;
+ }
+ }
+ if (done)
+ break;
+ thread = thread->next;
+ }
+ }
+ }
+
/* return value depends on action requested */
if (flag & (MUTT_THREAD_COLLAPSE | MUTT_THREAD_UNCOLLAPSE))
- {
- if (roothdr)
- roothdr->num_hidden = num_hidden + 1;
return (final);
- }
else if (flag & MUTT_THREAD_UNREAD)
return ((old && new) ? new : (old ? old : new));
else if (flag & MUTT_THREAD_NEXT_UNREAD)