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 { if len(uids) == 0 {
return return
} }
store.selected += delta idx := store.SelectedIndex() + delta
if store.selected < 0 { store.Select(idx)
store.selected = 0
}
if store.selected >= len(uids) {
store.selected = len(uids) - 1
}
store.updateVisual() store.updateVisual()
nextResultIndex := len(store.results) - store.resultIndex - 2*delta nextResultIndex := len(store.results) - store.resultIndex - 2*delta
if nextResultIndex < 0 || nextResultIndex >= len(store.results) { if nextResultIndex < 0 || nextResultIndex >= len(store.results) {