Skip to content

Handle EOF in limited ask prompts - #937

Open
JoelTowell wants to merge 2 commits into
rails:mainfrom
JoelTowell:fix-ask-filtered-issue
Open

JoelTowell wants to merge 2 commits into
rails:mainfrom
JoelTowell:fix-ask-filtered-issue

Conversation

@JoelTowell

Copy link
Copy Markdown
Contributor

🌈

Problem

ask_simply already returns nil when input reaches EOF (here). That behaviour was added in #252, after #248 reported that Ctrl-D raised while handling a plain prompt.

ask_filtered uses ask_simply for limited_to prompts, but passes the result straight into answer_match (here). So EOF does not take the same path as an unlimited prompt. The case-sensitive path keeps reasking because nil does not match one of the allowed answers. The case-insensitive path raises because answer_match calls downcase on the answer (here).

Closes #935.

Reproduction

The first commit on this branch adds failing examples for this. It can be checked out independently to see the failure.

Solution

Return from ask_filtered when ask_simply returns nil, matching the EOF behaviour already used by plain prompts.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limited prompts do not return cleanly at end of input

1 participant