The current implementation assumes that 'root[0].FirstChild' is nil, but
this is not always the case. Instead of overwriting the FirstChild,
detect and link the messages to the LastChild of root[0].
Fixes: 672b4edca7af2303cfcb1d69a676556d12476b5f
Fixes: https://lists.sr.ht/~rjarry/aerc-devel/%3C20240305231305.44287-4-julio.bacel%40gmail.com%3E
Signed-off-by: Julio B <julio.bacel@gmail.com>
---
worker/notmuch/lib/database.go | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/worker/notmuch/lib/database.go b/worker/notmuch/lib/database.go
index 7216274a..9a8a9a60 100644
--- a/worker/notmuch/lib/database.go+++ b/worker/notmuch/lib/database.go
@@ -139,7 +139,10 @@ func (db *DB) ThreadsFromQuery(ctx context.Context, q string, entireThread bool)
root := db.makeThread(nil, &tlm, entireThread)
if len(root) > 1 {
root[0].Dummy = true
- root[0].FirstChild = root[0].NextSibling+ fc := &(root[0].FirstChild)+ for ; *fc != nil; fc = &((*fc).NextSibling) {+ }+ *fc = root[0].NextSibling root[0].NextSibling.PrevSibling = nil
root[0].NextSibling = nil
for i := 1; i < len(root); i++ {
--
2.44.0
This indeed improves over the previous situation, but I worry that we may be
inducing obscure bugs that might be very hard to detect. I don't have a
solution, either.
Tested-By: inwit <inwit@sindominio.net>
Julio B <julio.bacel@gmail.com> wrote:
> The current implementation assumes that 'root[0].FirstChild' is nil, but> this is not always the case. Instead of overwriting the FirstChild,> detect and link the messages to the LastChild of root[0].>> Fixes: 672b4edca7af2303cfcb1d69a676556d12476b5f> Fixes: https://lists.sr.ht/~rjarry/aerc-devel/%3C20240305231305.44287-4-julio.bacel%40gmail.com%3E> Signed-off-by: Julio B <julio.bacel@gmail.com>> ---
Acked-by: Robin Jarry <robin@jarry.cc>
Applied with cleanup of Fixes trailer, thanks.
To git@git.sr.ht:~rjarry/aerc
805a29aef932..0a1af14fd916 master -> master