From 159ad244ee23d69f2491b139fd4384c7620b83c2 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Mon, 6 Mar 2023 23:32:55 +0100 Subject: msglist: fix inconsistent thread subject deduplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When threading is enabled, some messages which have different base subjects are hidden whereas some others which have similar subjects are displayed: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed ├─>[PATCH aerc v3 2/3] mk: only install changed/missing files │ └─>Re: [PATCH aerc v3 2/3] mk: only install changed/missing files │ └─>Re: [PATCH aerc v3 2/3] mk: only install changed/missing files ├─> └─>Re: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed This happens because we are using the "previous" message to get the subject base instead of the current one. Compute the base subject from the current message. Here is the result: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed ├─>[PATCH aerc v3 2/3] mk: only install changed/missing files │ └─> │ └─> ├─>[PATCH aerc v3 3/3] mk: speed up notmuch detection └─>Re: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed Fixes: 535300cfdbfc ("config: add columns based index format") Signed-off-by: Robin Jarry Acked-by: Tim Culverhouse --- widgets/msglist.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/widgets/msglist.go b/widgets/msglist.go index ab8b89fa..24f3d3bf 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -6,6 +6,7 @@ import ( "math" "strings" + sortthread "github.com/emersion/go-imap-sortthread" "github.com/gdamore/tcell/v2" "git.sr.ht/~rjarry/aerc/config" @@ -158,7 +159,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) { continue } - baseSubject := data.SubjectBase() + baseSubject := threadSubject(store, thread) data.ThreadSameSubject = baseSubject == lastSubject && sameParent(thread, prevThread) && !isParent(thread) @@ -466,3 +467,12 @@ func sameParent(left, right *types.Thread) bool { func isParent(t *types.Thread) bool { return t == t.Root() } + +func threadSubject(store *lib.MessageStore, thread *types.Thread) string { + msg, found := store.Messages[thread.Uid] + if !found || msg == nil || msg.Envelope == nil { + return "" + } + subject, _ := sortthread.GetBaseSubject(msg.Envelope.Subject) + return subject +} -- cgit v1.2.3-54-g00ecf