AlecAivazis / survey

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

Prompt again #165

Closed orymate closed 5 years ago

orymate commented 5 years ago

Recall the previous invalid input in the repeated Editor prompt so the user doesn't have to start over typing a long answer (for example a json structure).

Add optional PromptAgain method to Prompts to back this.

orymate commented 5 years ago

Hello @AlecAivazis, could you please check this PR?

AlecAivazis commented 5 years ago

Hey @orymate - sorry for lagging a bit on this.

I think this makes sense. Forcing the user to re-enter something they were just working on seems like a bad user experience.

Overall, the code looks fine. Would you mind adding a test for this?

orymate commented 5 years ago

Hello, does the test in 75e46df make sense? I did not catch the intention behind the go routine I removed, but it triggered errors after the extension, while it did work for me sequentially.

AlecAivazis commented 5 years ago

Thanks for adding that - it looks like you changed an existing test to cover your needs which makes it hard to track test failures (since the test is really testing 2 different things). Could you move the test into another test case?

orymate commented 5 years ago

Added separate test.

orymate commented 5 years ago

@AlecAivazis, can I do anything more to have this merged?

AlecAivazis commented 5 years ago

Hey @orymate!

I tried to add a test that would showcase the behavior to tests/editor.go but I couldn't get it to work. Could you add one there as well so I can run this on my laptop? Having the automatic ones are helpful for regressions but i still would like something to run by hand

orymate commented 5 years ago

@AlecAivazis, I added the manual test code

AlecAivazis commented 5 years ago

Awesome! Thanks for adding that - worked like a charm.