charmbracelet / bubbles

TUI components for Bubble Tea 🫧
MIT License
5.56k stars 264 forks source link

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

Closed rdnt closed 9 months ago

rdnt commented 9 months ago

Fixes a possible panic in case CurrentSuggestion is called on an empty input.

maaslalani commented 9 months ago

Hey @rdnt, nice catch. Instead of checking if the len of the array is zero we can check if the index >= the length which will catch this empty case and other cases where it may panic.

rdnt commented 9 months ago

Hi! :D Committed the suggestion, thanks!