Skip to content

gh-132267: fix desynchronized cursor position and buffer mismatch after resize #132360

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ImFeH2
Copy link
Contributor

@ImFeH2 ImFeH2 commented Apr 10, 2025

@ImFeH2
Copy link
Contributor Author

ImFeH2 commented Apr 10, 2025

before

before

after

after

@feoh
Copy link
Contributor

feoh commented May 19, 2025

Hi! I tested this PR on my Mac, MacOS latest and it works great.

It also helped me find another Pyrepl bug.

Copy link
Contributor

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

This has conflicts now.

@feoh
Copy link
Contributor

feoh commented May 19, 2025

Hi. I think I found a bug with this PR. Tested on MacOS latest. I reproduced this in WezTerm and also Apple's Terminal.app.

2025-05-19 13 30 23

In particular, if you type or paste a very long line into the terminal with this patch, leaving your cursor at the end, and then hit Ctrl/Cmd+/- a number of times to resize the text, you'll find the cursor in the middle of the line.

@ImFeH2
Copy link
Contributor Author

ImFeH2 commented May 20, 2025

Thanks @feoh for catching that bug!
I made a mistake there. The previous method wasn't working well because reflow is terminal application behavior, making it difficult to guess rearranged content at this level. Now I just clear the screen and redraw everything to prevent any leftover characters.
I've tested this in Windows Terminal with WSL and it handles content exceeding window height well.
Does this fix it? Open to suggestions.

@feoh
Copy link
Contributor

feoh commented May 20, 2025

@ImFeH2 Hi! I'm delighted I could help!

Went to re-test and for some reason I can't check out this PR:

╭─cpatti at rocinante in ~/src/personal/cpython on main✔ 25-05-20 - 16:40:49
╰─⠠⠵ gh pr checkout 132360                                              <region:us-east-1>
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 53 (delta 20), reused 19 (delta 19), pack-reused 24 (from 1)
Unpacking objects: 100% (53/53), 64.06 KiB | 1.56 MiB/s, done.
From github.com:python/cpython
 ! [rejected]                refs/pull/132360/head -> gh-132267  (non-fast-forward)
failed to run git: exit status 1

I'll try a fresh CPython checkout later from the hotel and see if that helps :)

@feoh
Copy link
Contributor

feoh commented May 21, 2025

Hi I'm very sorry to be the bearer of bad tidings but I'm seeing more issues with the fixed fix :\

2025-05-21 09 46 01

@ImFeH2
Copy link
Contributor Author

ImFeH2 commented May 24, 2025

Hi @feoh, are you referring to screen flickering or another issue? My expectations for REPL behavior might differ from yours, so clarification would be helpful. Thanks!
Would you mind if I include you as a co-author in this PR?

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.

3 participants