diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-07-23 21:03:43 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-24 23:05:00 +0200 |
commit | 4036f696ad359d503922c67b3a32d212a1bda987 (patch) | |
tree | 155c402f32255f357595f42fc0537ad1845555ec | |
parent | f8e6478d461c8f8224c49b4186cedd1566b72144 (diff) | |
download | aerc-4036f696ad359d503922c67b3a32d212a1bda987.zip |
msgstore: refactor NextPrev
Refactor NextPrev to use already existing selection methods and bounds
checking
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r-- | lib/msgstore.go | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 42795af..3a78e9e 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -675,13 +675,8 @@ func (store *MessageStore) NextPrev(delta int) { if len(uids) == 0 { return } - store.selected += delta - if store.selected < 0 { - store.selected = 0 - } - if store.selected >= len(uids) { - store.selected = len(uids) - 1 - } + idx := store.SelectedIndex() + delta + store.Select(idx) store.updateVisual() nextResultIndex := len(store.results) - store.resultIndex - 2*delta if nextResultIndex < 0 || nextResultIndex >= len(store.results) { |