Skip to content

Commit

Permalink
fix panic
Browse files Browse the repository at this point in the history
  • Loading branch information
go-to-k committed Aug 19, 2024
1 parent f0f71a4 commit c8b63ba
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions internal/io/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,13 @@ func (u *UI) View() string {

if len(contents) > SelectionPageSize {
switch {
case u.Cursor < SelectionPageSize/2:
case u.Filtered.Cursor < SelectionPageSize/2:
contents = contents[:SelectionPageSize]
case u.Cursor > len(u.Choices)-SelectionPageSize/2:
contents = contents[len(u.Choices)-SelectionPageSize:]
case u.Filtered.Cursor > len(contents)-SelectionPageSize/2:
contents = contents[len(contents)-SelectionPageSize:]
default:
contents = contents[u.Cursor-SelectionPageSize/2 : u.Cursor+SelectionPageSize/2]
contents = contents[u.Filtered.Cursor-SelectionPageSize/2 : u.Filtered.Cursor+SelectionPageSize/2]
}

contents = contents[:SelectionPageSize]
}

s += strings.Join(contents, "")
Expand Down

0 comments on commit c8b63ba

Please sign in to comment.