summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-07-23 21:03:43 -0500
committerRobin Jarry <robin@jarry.cc>2022-07-24 23:05:00 +0200
commit4036f696ad359d503922c67b3a32d212a1bda987 (patch)
tree155c402f32255f357595f42fc0537ad1845555ec
parentf8e6478d461c8f8224c49b4186cedd1566b72144 (diff)
downloadaerc-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.go9
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) {