gh-144259: Fix Windows EOL wrap by syncing real console cursor #144297
gh-144259: Fix Windows EOL wrap by syncing real console cursor #144297hyongtao-code wants to merge 14 commits intopython:mainfrom
Conversation
Windows VT terminals do not consistently wrap the cursor when a line exactly fills the terminal width. Previously we assumed a wrap always happened, which could desynchronize the logical cursor from the real console cursor and break subsequent cursor movement. This change queries the real cursor position and updates posxy accordingly, and adds regression tests for both wrap and no-wrap cases. Signed-off-by: Yongtao Huang <[email protected]>
Co-authored-by: Chris Eibl <[email protected]>
|
Thanks for the review! I agree with your point, so I’ve removed the VT-specific references and updated the tests to exercise both VT and legacy console modes. |
Fall back gracefully when querying the console cursor fails with an invalid handle, instead of raising an exception. Failed link: https://github.com/python/cpython/actions/runs/21563046527/job/62130029686?pr=144297
|
As you've seen, many Windows tests fail now, because in headless mode Instead of swallowing the error, maybe introduce something like Then, we can simply mock this for most of the tests. And you can also write an explicit test for |
|
Thanks for the suggestion — these failed cases were indeed quite tricky. I decided to follow your proposed approach to fix the failing cases. |
Co-authored-by: Chris Eibl <[email protected]>
Co-authored-by: Chris Eibl <[email protected]>
|
Thanks for the review and guidance. With mocks, we can preserve the original logic and avoid hacky workarounds for CI-specific failures. |
|
Thanks for your patience. |
|
Thanks for your patience and contribution. |
Long log:
Windows VT terminals do not consistently wrap the cursor when a line
exactly fills the terminal width.
Previously we assumed a wrap always happened, which could desynchronize
the logical cursor from the real console cursor and break subsequent
cursor movement.
This change queries the real cursor position and updates posxy
accordingly, and adds regression tests for both wrap and no-wrap cases.
Video with the patch
fix-issue-144259-V2.mp4
Signed-off-by: Yongtao Huang [email protected]