diff --git a/wdgt_searcher.go b/wdgt_searcher.go index c39a774..918558f 100644 --- a/wdgt_searcher.go +++ b/wdgt_searcher.go @@ -105,11 +105,17 @@ func (w *Searcher) HandleKey(ev *tcell.EventKey) bool { } func (w *Searcher) handleKeyUp(ev *tcell.EventKey) bool { + if len(w.filteredData) == 0 { + return false + } w.cursor = ((w.cursor - 1) + len(w.filteredData)) % len(w.filteredData) return true } func (w *Searcher) handleKeyDown(ev *tcell.EventKey) bool { + if len(w.filteredData) == 0 { + return false + } w.cursor = ((w.cursor + 1) + len(w.filteredData)) % len(w.filteredData) return true } @@ -262,7 +268,8 @@ func (w *Searcher) MinH() int { func (w *Searcher) SetHideOnSelect(t bool) { w.hideOnSelect = t } func (w *Searcher) SetTitle(ttl string) { w.title = ttl } func (w *Searcher) SetData(data []string) { - w.data = data + // w.data = data + w.filteredData = data w.updateFilter() }