Skip to content

Commit

Permalink
fix(textinput): out of range panic if no matched suggestions (#473)
Browse files Browse the repository at this point in the history
* fix(textinput): out of range panic if no matched suggestions

* fix(textinput): out of bounds check

Co-authored-by: Maas Lalani <maas@lalani.dev>

---------

Co-authored-by: Maas Lalani <maas@lalani.dev>
  • Loading branch information
rdnt and maaslalani authored Feb 2, 2024
1 parent 364eac9 commit 79cc962
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions textinput/textinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,10 @@ func (m *Model) AvailableSuggestions() []string {

// CurrentSuggestion returns the currently selected suggestion.
func (m *Model) CurrentSuggestion() string {
if m.currentSuggestionIndex >= len(m.matchedSuggestions) {
return ""
}

return string(m.matchedSuggestions[m.currentSuggestionIndex])
}

Expand Down

0 comments on commit 79cc962

Please sign in to comment.