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

[AlecAivazis/survey#96] add support for tab completion on input #304

Closed lucassabreu closed 3 years ago

lucassabreu commented 3 years ago

related to AlecAivazis/survey#96

lucassabreu commented 3 years ago

i will create a new section similar to "filtering options" on how to use the new feature. but the code i think is done

lucassabreu commented 3 years ago

thank you @AlecAivazis, i am glad you liked it.

i implemented the tab to go to next item for the suggestions now.

i also realized the select and multiselect does not have this behavior and will implement on then.

AlecAivazis commented 3 years ago

@lucassabreu this PR seems to have broken the ability for the user to use arrow keys in order to navigate the input string :( I'd like to bring that functionality back, do you mind giving it a shot? If not, I can try to find some time

lucassabreu commented 3 years ago

hi @AlecAivazis , I can look into it, but can you explain how to reproduce it? is just about moving the cursor on the input?

AlecAivazis commented 3 years ago

awesome! If you run any of the tests in input.go you'll see what i mean if you type a few characters and then try to press an arrow key to move left or right.

AlecAivazis commented 3 years ago

The issue is because input calls RuneReader.ReadRune instead of ReadLine which handles new characters inserted at arbitrary places in the input.

AlecAivazis commented 3 years ago

I tried to sneak in some time this morning to get started on this but have to get back to work and might not have time to see it through to the end for a little. Here is my branch if you want to take a look (feel free to ignore it entirely if you have a better approach). The input and help tests work but I haven't tried adding any suggestions yet. We probably want to add an example with suggestions to the test suite so we can ensure the functionality stays.

lucassabreu commented 3 years ago

right i will try to continue from the branch. i think i left some tests... but will try to add more if needed.

AlecAivazis commented 3 years ago

Thanks for picking this up! I really appreciate it

lucassabreu commented 3 years ago

trying to fix in the pr #361