From 8689d712a31681f01b60f02d1a7fabebe9fc468f Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sat, 7 Jan 2017 17:42:33 +0300 Subject: [PATCH] make search cyclic Mentioned in #57. --- nav.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nav.go b/nav.go index 69be244..71468c3 100644 --- a/nav.go +++ b/nav.go @@ -372,6 +372,12 @@ func (nav *nav) searchNext() { return } } + for i := 0; i < last.ind; i++ { + if strings.Contains(last.fi[i].Name(), nav.search) { + nav.up(last.ind - i) + return + } + } } func (nav *nav) searchPrev() { @@ -382,6 +388,12 @@ func (nav *nav) searchPrev() { return } } + for i := len(last.fi) - 1; i > last.ind; i-- { + if strings.Contains(last.fi[i].Name(), nav.search) { + nav.down(i - last.ind) + return + } + } } func (nav *nav) toggleMark(path string) {