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>
This commit is contained in:
Tim Culverhouse 2022-07-23 21:03:43 -05:00 committed by Robin Jarry
parent f8e6478d46
commit 4036f696ad

View file

@ -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) {