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:
parent
f8e6478d46
commit
4036f696ad
1 changed files with 2 additions and 7 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue