diff options
| author | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2021-08-10 01:16:52 +0300 |
|---|---|---|
| committer | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2021-08-10 22:10:39 +0300 |
| commit | b7844358d277a3779ec4c03cb7c8e42cd5479682 (patch) | |
| tree | 784e46259cf6eb75a20bde4ec33e633d0c3ca386 | |
| parent | c29368af930461a4ad8fc62b99c0f49cb8fcf330 (diff) | |
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.
| -rw-r--r-- | lib/mu-query-threads.cc | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/mu-query-threads.cc b/lib/mu-query-threads.cc index 8c4759f..fa1bb67 100644 --- a/lib/mu-query-threads.cc +++ b/lib/mu-query-threads.cc @@ -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(); } } |
