Skip to content

gh-127073: Clear completion list when KeyboardInterrupt occurs in REPL #128467

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions Lib/_pyrepl/simple_interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def maybe_run_command(statement: str) -> bool:
r = _get_reader()
if r.input_trans is r.isearch_trans:
r.do_cmd(("isearch-end", [""]))
if r.cmpltn_menu_choices:
r.cmpltn_reset()
r.pos = len(r.get_unicode())
r.dirty = True
r.refresh()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Previously in the REPL, when a completion list was displayed and KeyboardInterrupt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the effort, but this is too long. Can we shorten this to a single sentence? (We don't need technical details, just what was fixed.)

was triggered using Ctrl+C, the completion list would persist and duplicate with
each KeyboardInterrupt. Now, when KeyboardInterrupt occurs, the completion list
is properly cleared, consistent with the behavior of other errors.
Loading