From 0a1af14fd91640cc19f7e06d7fd70b9424b459cc Mon Sep 17 00:00:00 2001 From: Julio B Date: Sun, 14 Apr 2024 01:27:44 +0300 Subject: notmuch: fix disappearing messages 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: 672b4edca7af ("notmuch: draw incomplete threads") Signed-off-by: Julio B Tested-by: Inwit Acked-by: Robin Jarry --- worker/notmuch/lib/database.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'worker') 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++ { -- cgit