-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to cancel console-ui prompts #1035
Comments
@mattirn ? |
@quintesse, I think that the possibility canceling prompts would be nice to have... I wrote an other similar ticket #1042 if you are interested to create PR also for it. |
hi @mattirn , that's indeed an issue that's very related to this one! In fact ESC could simply be used to cancel the current question, which would then mean returning to the previous one. And only when you hit ESC on the first question would we exit. That seems like a good way to fix both issues. |
Cancelling a prompt by hitting the ESC key makes it go back to the previous prompt. If we're already at the fist prompt the result returned will be `null`. Fixes jline#1035
I opened a PR for this feature, not sure if this is how you'd want to tackle this, but I wanted to maintain backwards compatibility, meaning that old code doesn't suddenly reacts differently by allowing prompts to be cancelled when before that wasn't possible. How it works is that at any time the user can hit the ESC key and that will cancel the current prompt item. If there were previously answered prompts the code will back up a single question and re-execute that prompt. If we were at the first or only prompt the result of the entire prompt will be How it was implemented:
This gives devs a very simple way to enable this feature, they can simply change a line like:
to:
and they'll have opted in to the new feature. I thought about making it possible to set this property on a per-item basis but it would mean a lot more changes while not making the feature much more useful. (Is it really useful to be able to cancel some questions but not others?) I also thought about adding the |
Cancelling a prompt by hitting the ESC key makes it go back to the previous prompt. By default, if we're already at the fist prompt we'll repeat the question until the user either answers it or forcefully quits the application. If on the other hand the `cancellableFirstPrompt` option of `UiConfig` has been set to `true`, the `prompt()` method will return `null`. Fixes jline#1035
Cancelling a prompt by hitting the ESC key makes it go back to the previous prompt. By default, if we're already at the fist prompt we'll repeat the question until the user either answers it or forcefully quits the application. If on the other hand the `cancellableFirstPrompt` option of `UiConfig` has been set to `true`, the `prompt()` method will return `null`. Fixes jline#1035
Cancelling a prompt by hitting the ESC key makes it go back to the previous prompt. By default, if we're already at the fist prompt we'll repeat the question until the user either answers it or forcefully quits the application. If on the other hand the `cancellableFirstPrompt` option of `UiConfig` has been set to `true`, the `prompt()` method will return `null`. Fixes jline#1035
Right now you can only EXIT by making a selection or hitting enter, etc. It would be nice to be able to cancel out of a prompt, for example by using the escape key.
Doing that by default might not be backward-compatible, but perhaps we could add a
.cancelable(true)
option to the prompt builders which would then add an extra CANCEL action to the prompt's key bindings. If the user then hits the escape key we could have the prompt returnnull
to indicate that the prompt was cancelled..If there's interest for this feature I could try to create a PR for it.
The text was updated successfully, but these errors were encountered: