aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-08-12 23:15:42 +0200
committerRobin Jarry <robin@jarry.cc>2022-08-22 10:01:46 +0200
commit588be1a28422a6c431f11f820af73e99f11342c6 (patch)
tree4d1d2e94e5e71b5c48426fe17cebe1ca5832b452 /widgets
parentd138da0c9fe40ae1adb152da4a22bea2fb86be19 (diff)
downloadaerc-588be1a28422a6c431f11f820af73e99f11342c6.tar.gz
store: improve cursor position
Improve cursor re-positioning while filtering with and without threads. Reposition cursor in client-side threading mode with a callback that is set during store.NextPrev(). Run callback when the threads are constructed in order to reposition the cursor correctly. The callback is deactivated when store.Select() is called. Steps to reproduce two issues: * Reproduce issue 1: 1. Activate client-side threading 2. Apply a filter, e.g. :filter -f Koni 3. Move cursor around so that a message is highlighted 4. clear filter with :clear 5. The cursor is expected to remain on the selected message but is actually not * Reproduce issue 2: 1. Activate client-side threading 2. Go the end of the message list 2. Apply a filter, e.g. :filter -f Koni 5. The cursor is now at the end of the filtered results instead of at the beginning This patch fixes both of those issues. Tested in regular and threaded view according to the following check list (expected behavior in parenthesis): 1. Apply filter from a message that remains in the filter (cursor on message, message selected) 2. Apply filter from a message that will not remain (cursor at the top, no message selected) 3. Clear filter (cursor remains on message, message selected) 4. Scroll line-by-line (threads: cursor remains on line, does not "jump" with message) 5. Search (cursor on first result) Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/msglist.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 935566f8..ba09a8ec 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -70,9 +70,11 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
ml.UpdateScroller(ml.height, len(store.Uids()))
if store := ml.Store(); store != nil && len(store.Uids()) > 0 {
- if idx := store.FindIndexByUid(store.SelectedUid()); idx >= 0 {
- ml.EnsureScroll(len(store.Uids()) - idx - 1)
+ idx := store.FindIndexByUid(store.SelectedUid())
+ if idx < 0 {
+ idx = len(store.Uids()) - 1
}
+ ml.EnsureScroll(len(store.Uids()) - idx - 1)
}
textWidth := ctx.Width()