about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorKevin Kuehler <keur@ocf.berkeley.edu>2019-07-21 18:26:37 -0700
committerDrew DeVault <sir@cmpwn.com>2019-07-25 08:26:43 -0400
commitfe2fef4b750e570361eabc849c1ec09fe5eda01d (patch)
treefe2b808599d2720811ed81fa7f1a4dd955319afb /lib
parent6c0f228451c171f4901fa214dd8252d2b22bceaa (diff)
downloadaerc-fe2fef4b750e570361eabc849c1ec09fe5eda01d.tar.gz
Make :next-result :prev-result relative to cursor
Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
Diffstat (limited to 'lib')
-rw-r--r--lib/msgstore.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index baf8ee4..736217e 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -321,6 +321,15 @@ func (store *MessageStore) nextPrev(delta int) {
 	if store.selected >= len(store.uids) {
 		store.selected = len(store.uids) - 1
 	}
+	nextResultIndex := len(store.results) - store.resultIndex - 2*delta
+	if nextResultIndex < 0 || nextResultIndex >= len(store.results) {
+		return
+	}
+	nextResultUid := store.results[nextResultIndex]
+	selectedUid := store.uids[len(store.uids)-store.selected-1]
+	if nextResultUid == selectedUid {
+		store.resultIndex += delta
+	}
 }
 
 func (store *MessageStore) Next() {