Skip to content

Commit

Permalink
fix(filter): panic if no matches
Browse files Browse the repository at this point in the history
closes #715

Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Nov 18, 2024
1 parent 20a381a commit 3cec9b7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

func (m *model) CursorUp() {
if len(m.matches) == 0 {
return
}
if m.reverse { //nolint:nestif
m.cursor = (m.cursor + 1) % len(m.matches)
if len(m.matches)-m.cursor <= m.viewport.YOffset {
Expand All @@ -275,6 +278,9 @@ func (m *model) CursorUp() {
}

func (m *model) CursorDown() {
if len(m.matches) == 0 {
return
}
if m.reverse { //nolint:nestif
m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches)
if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset {
Expand Down

0 comments on commit 3cec9b7

Please sign in to comment.