Skip to content

gh-140131: Fix REPL cursor position on Windows when module completion suggestion line hits console width#140333

Open
tanloong wants to merge 18 commits intopython:mainfrom
tanloong:fix-repl-cursor-pos-windows-module-completion
Open

gh-140131: Fix REPL cursor position on Windows when module completion suggestion line hits console width#140333
tanloong wants to merge 18 commits intopython:mainfrom
tanloong:fix-repl-cursor-pos-windows-module-completion

Conversation

@tanloong
Copy link
Contributor

@tanloong tanloong commented Oct 19, 2025

This skips handling the wrapping in self.__write_changed_line() when wlen(newline)==self.width, and simply updates self.posxy (explained in #140131 (comment)).

One thing that happens after the skip is that the cursor moves leftward by one character on Tab key:

WindowsTerminal_eDpHfMhTvA.mp4

As noted in this comment, "when writing to the final character on the line, the cursor location is effectively moved one element backwards." So, we account for this 1-character offset by setting the cursor column to a maximum of self.width-1.

WindowsTerminal_0fSumUhJoh.mp4

@tanloong tanloong marked this pull request as ready for review October 20, 2025 14:32
@tanloong tanloong marked this pull request as draft October 20, 2025 15:35
@tanloong tanloong marked this pull request as ready for review October 25, 2025 16:22
@tanloong
Copy link
Contributor Author

tanloong commented Feb 9, 2026

@chris-eibl I've added tests for this.

@chris-eibl chris-eibl self-requested a review February 10, 2026 18:48
@chris-eibl
Copy link
Member

Lgtm. Since this also solves #144259, can you add a second blurb?

@tanloong
Copy link
Contributor Author

tanloong commented Feb 11, 2026

Thank you for the review! Added the second blurb.

Copy link
Member

@chris-eibl chris-eibl left a comment

Choose a reason for hiding this comment

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

Lgtm. This is now ready for core dev review. Thank you for your contribution.

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