Skip to content

Commit

Permalink
fix: another panic, wtf
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Oct 31, 2023
1 parent dd1a58f commit 6e2d3ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/fuzzy/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (f *Fuzzy) Update(msg tea.Msg) (taro.Model, tea.Cmd) {
return f, taro.WaitScreens(f.Ctx(), f.anim)
case matchResult:
f.filtered = msg.Filtered
f.selected = geom.Max(geom.Min(f.selected, len(f.getOptions())-1), 0)
f.selected = geom.Clamp(f.selected, 0, len(f.getOptions())-1)
return f, nil
case tea.WindowSizeMsg:
size := geom.Size{
Expand All @@ -147,7 +147,7 @@ func (f *Fuzzy) Update(msg tea.Msg) (taro.Model, tea.Cmd) {
if f.isInverted() {
delta = 1
}
f.selected = geom.Clamp(f.selected+delta, 0, len(f.getOptions()))
f.selected = geom.Clamp(f.selected+delta, 0, len(f.getOptions())-1)
return f, f.handlePreview()
case taro.KeyDown, taro.KeyCtrlJ:
f.haveMoved = true
Expand Down

0 comments on commit 6e2d3ac

Please sign in to comment.