diff options
author | Koni Marti <koni.marti@gmail.com> | 2024-05-14 23:43:12 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-05-28 23:52:40 +0200 |
commit | 2276a796f36cb6e213aca3b760b411202ed24e0e (patch) | |
tree | fb3f172cd733e1d768ff6099b4a6f3a6de439c98 /lib/msgstore.go | |
parent | 9f97c698e3dd8bb98242f0db40946dee514e3ee8 (diff) | |
download | aerc-2276a796f36cb6e213aca3b760b411202ed24e0e.tar.gz |
ui: add select-last-message option
Add a [ui].select-last-message option to position the cursor at the
bottom of the message list view.
Fixes: https://todo.sr.ht/~rjarry/aerc/254
Changelog-added: Add `[ui].select-last-message` option to position
cursor at the bottom of the view.
Suggested-by: Bence Ferdinandy <bence@ferdinandy.com>
Requested-by: Tomasz Kramkowski <tomasz@kramkow.ski>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tomasz Kramkowski <tomasz@kramkow.ski>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r-- | lib/msgstore.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 8f626eb8..b4790735 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -48,6 +48,7 @@ type MessageStore struct { sortDefault []*types.SortCriterion threadedView bool + selectLast bool reverseThreadOrder bool threadContext bool sortThreadSiblings bool @@ -89,6 +90,7 @@ const MagicUid = 0xFFFFFFFF func NewMessageStore(worker *types.Worker, defaultSortCriteria []*types.SortCriterion, thread bool, clientThreads bool, clientThreadsDelay time.Duration, + selectLast bool, reverseOrder bool, reverseThreadOrder bool, sortThreadSiblings bool, triggerNewEmail func(*models.MessageInfo), triggerDirectoryChange func(), triggerMailDeleted func(), @@ -116,6 +118,7 @@ func NewMessageStore(worker *types.Worker, threadedView: thread, buildThreads: clientThreads, threadContext: threadContext, + selectLast: selectLast, reverseThreadOrder: reverseThreadOrder, sortThreadSiblings: sortThreadSiblings, @@ -745,7 +748,11 @@ func (store *MessageStore) Selected() *models.MessageInfo { func (store *MessageStore) SelectedUid() uint32 { if store.selectedUid == MagicUid && len(store.Uids()) > 0 { iter := store.UidsIterator() - store.Select(store.Uids()[iter.StartIndex()]) + idx := iter.StartIndex() + if store.selectLast { + idx = iter.EndIndex() + } + store.Select(store.Uids()[idx]) } return store.selectedUid } |