From 79cc9621d5244455ee955e0f3548287b1d3113b2 Mon Sep 17 00:00:00 2001 From: Tasos Papalyras Date: Fri, 2 Feb 2024 23:02:24 +0200 Subject: [PATCH] fix(textinput): out of range panic if no matched suggestions (#473) * fix(textinput): out of range panic if no matched suggestions * fix(textinput): out of bounds check Co-authored-by: Maas Lalani --------- Co-authored-by: Maas Lalani --- textinput/textinput.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/textinput/textinput.go b/textinput/textinput.go index 501f9a7..24e0b6e 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -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]) }