Skip to content

Commit

Permalink
click.confirm preserves prompt when readline is imported
Browse files Browse the repository at this point in the history
same fix as for click.prompt in 8.0.0
  • Loading branch information
alex-ball authored and davidism committed Oct 10, 2021
1 parent 3737511 commit d8f418a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -7,6 +7,8 @@ Unreleased

- Fix issue with ``Path(resolve_path=True)`` type creating invalid
paths. :issue:`2088`
- Importing ``readline`` does not cause the ``confirm()`` prompt to
disappear when pressing backspace. :issue:`2092`


Version 8.0.2
Expand Down
6 changes: 4 additions & 2 deletions src/click/termui.py
Expand Up @@ -231,8 +231,10 @@ def confirm(
try:
# Write the prompt separately so that we get nice
# coloring through colorama on Windows
echo(prompt, nl=False, err=err)
value = visible_prompt_func("").lower().strip()
echo(prompt.rstrip(" "), nl=False, err=err)
# Echo a space to stdout to work around an issue where
# readline causes backspace to clear the whole line.
value = visible_prompt_func(" ").lower().strip()
except (KeyboardInterrupt, EOFError):
raise Abort() from None
if value in ("y", "yes"):
Expand Down

0 comments on commit d8f418a

Please sign in to comment.