cpython icon indicating copy to clipboard operation
cpython copied to clipboard

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

Open treyhunner opened this issue 1 year ago • 1 comments

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 https://github.com/python/cpython/issues/111201#issuecomment-2101869843

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

treyhunner avatar May 10 '24 14:05 treyhunner

I'll give this a go

aelsayed95 avatar May 20 '24 18:05 aelsayed95

This has been fixed! Congrats @aelsayed95! 🎉

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

lysnikolaou avatar May 23 '24 04:05 lysnikolaou