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

Editing the last line in a block in the new REPL is buggy #118911

Closed
treyhunner opened this issue May 10, 2024 · 2 comments
Closed

Editing the last line in a block in the new REPL is buggy #118911

treyhunner opened this issue May 10, 2024 · 2 comments
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@treyhunner
Copy link
Member

treyhunner commented May 10, 2024

Bug report

Bug description:

When editing the last line in a function in the new REPL, hitting Enter doesn't end the block if the last line has indentation on it.

658451

Demo of the bug, demo of what IPython does

Originally posted in #111201 (comment)

Here are the noticeable differences in how IPython handles this situation:

  1. When hitting the up arrow key to edit the block, the final blank line isn't included (the default cursor position is at the end of the last non-empty line.

image

  1. In IPython I tried purposely adding extra whitespace-only lines (not fully blank but instead containing 4 spaces) by hitting Enter, up arrow, End, Enter, up arrow, End, repeatedly. If I then hit Enter on the first line-followed-by-whitespace-only-lines it ends the block.

image

  1. Hitting up arrow again, will strip whitespace from the end of the block (maybe this is how 1 above is implemented)

image

Implementing the behavior of 1 (or 3) above might be enough, though 2 seems like it would be even better.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

@treyhunner treyhunner added the type-bug An unexpected behavior, bug, or error label May 10, 2024
@treyhunner treyhunner mentioned this issue May 10, 2024
7 tasks
@hugovk hugovk added 3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell labels May 10, 2024
@aelsayed95
Copy link
Contributor

I'll give this a go

aelsayed95 added a commit to aelsayed95/cpython that referenced this issue May 21, 2024
ambv added a commit that referenced this issue May 22, 2024
…from terminating the code block (#119355)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
lysnikolaou pushed a commit to lysnikolaou/cpython that referenced this issue May 22, 2024
…ent the user from terminating the code block (pythonGH-119355)

(cherry picked from commit 5091c44)

Co-authored-by: Aya Elsayed <ayah.ehab11@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
lysnikolaou added a commit that referenced this issue May 23, 2024
…e user from terminating the code block (GH-119355) (#119404)

(cherry picked from commit 5091c44)

Co-authored-by: Aya Elsayed <ayah.ehab11@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
@lysnikolaou
Copy link
Contributor

This has been fixed! Congrats @aelsayed95! 🎉

I'm closing this, but feel free to reopen in case something's off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants