Skip to content

Commit

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

* fix(textinput): out of range panic if no matched suggestions

* fix(textinput): out of bounds check

Co-authored-by: Maas Lalani <[email protected]>

---------

Co-authored-by: Maas Lalani <[email protected]>
  • Loading branch information
rdnt and maaslalani authored Feb 2, 2024
1 parent 50967b3 commit 23409c0
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 23409c0

Please sign in to comment.