Skip to content

gh-159658: Fix the REPL mangling input when the prompt is wider than the terminal - #159659

Open
lazerg wants to merge 4 commits into
python:mainfrom
lazerg:fix-issue-159658
Open

lazerg wants to merge 4 commits into
python:mainfrom
lazerg:fix-issue-159658

Conversation

@lazerg

@lazerg lazerg commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

When the prompt fills the whole row, layout_content_lines() still forced one body character onto the prompt row, so the row overflowed the terminal and the first typed character got split from the rest. The force-progress fallback now only applies to rows without a prompt, so the prompt gets its own row and the input starts on the next one, the same as 3.14 does.

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please rebase against main to resolve the conflicts.

Comment thread Lib/_pyrepl/layout.py Outdated
column += char_width

if index_to_wrap_before == 0 and start < total:
if index_to_wrap_before == 0 and not current_prompt_width:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With a 65-column prompt in a 20-column terminal, this still adds a stray backslash and sends cursor moves past the margin. Can we split the prompt into physical rows and use those rows for cursor movement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in b480959: the prompt is now split into full-width rows in the layout map, so there is no backslash and up/down skip those rows instead of landing past the margin. I also merged main to fix the conflicts.

@bedevere-app

bedevere-app Bot commented Nov 26, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@lazerg

lazerg commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Hey @serhiy-storchaka, please take a look when you have time~

@lazerg

lazerg commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-app

bedevere-app Bot commented Nov 27, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@pablogsal: please review the changes made to this pull request.

@bedevere-app
bedevere-app Bot requested a review from pablogsal November 27, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants