From ceddb4f262d7cebf8cbfe53d0ccf4e799cbc956d Mon Sep 17 00:00:00 2001 From: Tasos Papalyras Date: Fri, 2 Feb 2024 22:04:00 +0200 Subject: [PATCH 1/2] fix(textinput): out of range panic if no matched suggestions --- textinput/textinput.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/textinput/textinput.go b/textinput/textinput.go index 501f9a79..62beb5d8 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 len(m.matchedSuggestions) == 0 { + return "" + } + return string(m.matchedSuggestions[m.currentSuggestionIndex]) } From 019f0adc9100408ed5bc7a7169891c0358476bc7 Mon Sep 17 00:00:00 2001 From: Tasos Papalyras Date: Fri, 2 Feb 2024 22:46:00 +0200 Subject: [PATCH 2/2] fix(textinput): out of bounds check Co-authored-by: Maas Lalani --- textinput/textinput.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/textinput/textinput.go b/textinput/textinput.go index 62beb5d8..24e0b6e2 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -830,7 +830,7 @@ func (m *Model) AvailableSuggestions() []string { // CurrentSuggestion returns the currently selected suggestion. func (m *Model) CurrentSuggestion() string { - if len(m.matchedSuggestions) == 0 { + if m.currentSuggestionIndex >= len(m.matchedSuggestions) { return "" }