From 318f7d252c6daa9c44b8ee8771bcb09c9ae82256 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Sat, 30 Jul 2022 17:36:56 +0200 Subject: [PATCH] notmuch: fix cursor movement in threaded view Set the SkipSort flag when sending directory infos for counting purposes. Without this, the directory infos would trigger a directory fetch which could bring the notmuch threads out of sync with the message list. The notmuch backend sends these directory infos automatically every minute. To reproduce the weird cursor movement in notmuch's threaded view: 1. enter threaded view in notmuch 2. wait 1 min (until the auto directory infos are sent out) 3. move cursor around and notice how it jumps over threads Signed-off-by: Koni Marti Tested-by: Tim Culverhouse --- worker/notmuch/eventhandlers.go | 2 +- worker/notmuch/worker.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/worker/notmuch/eventhandlers.go b/worker/notmuch/eventhandlers.go index 4eec1f6..7b3c517 100644 --- a/worker/notmuch/eventhandlers.go +++ b/worker/notmuch/eventhandlers.go @@ -16,7 +16,7 @@ func (w *worker) handleNotmuchEvent(et eventType) error { func (w *worker) handleUpdateDirCounts(ev eventType) error { for name, query := range w.nameQueryMap { - info, err := w.gatherDirectoryInfo(name, query) + info, err := w.buildDirInfo(name, query, true) if err != nil { logging.Errorf("could not gather DirectoryInfo: %v", err) continue diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index 6941809..28029b2 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -211,12 +211,18 @@ func (w *worker) handleListDirectories(msg *types.ListDirectories) error { } func (w *worker) gatherDirectoryInfo(name string, query string) ( + *types.DirectoryInfo, error) { + return w.buildDirInfo(name, query, false) +} + +func (w *worker) buildDirInfo(name string, query string, skipSort bool) ( *types.DirectoryInfo, error) { count, err := w.db.QueryCountMessages(query) if err != nil { return nil, err } info := &types.DirectoryInfo{ + SkipSort: skipSort, Info: &models.DirectoryInfo{ Name: name, Flags: []string{},