threads: recurse thread-subject check

Not only check for duplicate subjects in *siblings*, also recurse into
the children. This remove some clutter from deeply nested threads.

Fixes: #2078.
This commit is contained in:
Dirk-Jan C. Binnema 2021-08-10 01:16:52 +03:00
parent c29368af93
commit b7844358d2
1 changed files with 13 additions and 11 deletions

View File

@ -394,9 +394,8 @@ update_container (Container& container, bool descending,
if (!container.children.empty())
qmatch.flags |= QueryMatch::Flags::HasChild;
// see whether this message has the has the thread
// subject, ie.. the first message in this thread with the
// given subject.
// see whether this message has the thread subject, i.e., the
// first message in this thread with the given subject.
if (qmatch.has_flag(QueryMatch::Flags::Root) ||
//qmatch.has_flag(QueryMatch::Flags::Orphan) ||
prev_subject.empty() ||
@ -428,20 +427,20 @@ update_container (Container& container, bool descending,
static void
update_containers (Containers& children, bool descending, ThreadPath& tpath,
size_t seg_size)
size_t seg_size, const std::string& prev_subject)
{
size_t idx{0};
std::string last_subject;
std::string last_subject = prev_subject;
for (auto&& c: children) {
tpath.emplace_back(idx++);
if (c->query_match) {
update_container(*c, descending, tpath, seg_size,
update_container(*c, descending, tpath, seg_size,
last_subject);
last_subject = c->query_match->subject;
}
update_containers(c->children, descending, tpath, seg_size);
update_containers(c->children, descending, tpath, seg_size,
last_subject);
tpath.pop_back();
}
}
@ -457,9 +456,12 @@ update_containers (ContainerVec& root_vec, bool descending, size_t n)
size_t idx{0};
for (auto&& c: root_vec) {
tpath.emplace_back(idx++);
update_container(*c, descending, tpath, seg_size);
update_containers(c->children, descending, tpath, seg_size);
tpath.emplace_back(idx++);
std::string prev_subject;
if (update_container(*c, descending, tpath, seg_size))
prev_subject = c->query_match->subject;
update_containers(c->children, descending, tpath, seg_size,
prev_subject);
tpath.pop_back();
}
}