From bf02ad30ca118df09203ce34bba36a5fb9d5d450 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 26 Jun 2019 20:52:34 -0400 Subject: [PATCH] Fix jumping around in search --- widgets/msglist.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/widgets/msglist.go b/widgets/msglist.go index 3f7e2b3..211cbce 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -184,14 +184,7 @@ func (ml *MessageList) Selected() *types.MessageInfo { func (ml *MessageList) Select(index int) { store := ml.Store() store.Select(index) - - // I'm too lazy to do the math right now - for store.SelectedIndex()-ml.scroll >= ml.Height() { - ml.scroll += 1 - } - for store.SelectedIndex()-ml.scroll < 0 { - ml.scroll -= 1 - } + ml.Scroll() } func (ml *MessageList) Scroll() { @@ -201,9 +194,11 @@ func (ml *MessageList) Scroll() { return } if ml.Height() != 0 { - if store.SelectedIndex()-ml.scroll >= ml.Height() { + // I'm too lazy to do the math right now + for store.SelectedIndex()-ml.scroll >= ml.Height() { ml.scroll += 1 - } else if store.SelectedIndex()-ml.scroll < 0 { + } + for store.SelectedIndex()-ml.scroll < 0 { ml.scroll -= 1 } }