Skip to content
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

click.confirm does not cooperate with readline #2092

Closed
alex-ball opened this issue Oct 10, 2021 · 1 comment · Fixed by #2093
Closed

click.confirm does not cooperate with readline #2092

alex-ball opened this issue Oct 10, 2021 · 1 comment · Fixed by #2093
Milestone

Comments

@alex-ball
Copy link
Contributor

This follows on from #665.

Consider this code again, using click.confirm instead of click.prompt:

import click, readline
click.confirm("Input")
  • Type anything then backspace
    • Actual behaviour: the entire line is erased
    • Expected behaviour: only the entered character is erased
  • Type return only
    • Actual behaviour: no newline is printed to the terminal (a following click.echo() or print() will appear to be ignored)
    • Expected behaviour: a newline is printed to the terminal

The solution from PR #1836 seems to work in the case of click.confirm as well:

    while True:
        try:
            # Write the prompt separately so that we get nice
            # coloring through colorama on Windows
            echo(prompt.rstrip(" "), nl=False, err=err)
            value = visible_prompt_func(" ").lower().strip()

Environment:

  • Python version: 3.8.10
  • Click version: 8.0.1
@davidism davidism added this to the 8.0.3 milestone Oct 10, 2021
@davidism
Copy link
Member

Happy to review a PR

alex-ball added a commit to alex-ball/click that referenced this issue Oct 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants