AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.08k stars 351 forks source link

Panic index out of range; selectedIndex should not be a negative number #271

Closed jcpowermac closed 4 years ago

jcpowermac commented 4 years ago

When using AskOne, filtering and using arrow keys can result in a panic. Add checks to make sure that selectedIndex does not contain a negative number.

jcpowermac commented 4 years ago

Additional details in BZ if curious: https://bugzilla.redhat.com/show_bug.cgi?id=1775569

AlecAivazis commented 4 years ago

Would you mind cherry picking this onto v2?

jcpowermac commented 4 years ago

@AlecAivazis I have test code that I can try to see if I can reproduce with v2. There were differences so I don't think it will cleaning CP.

AlecAivazis commented 4 years ago

Ah that might definitely be the case. If you have the time to verify, that would save me having to add another item to my list of stuff to do 🙌

jcpowermac commented 4 years ago

@AlecAivazis tested with v2 no panic.

AlecAivazis commented 4 years ago

awesome! Thanks for checking