microsoft / microsoft/terminal
Prevent flickering due to scrolling when terminal is resized and cursor is off-screen
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
I've opened an issue about this before, but I still don't understand how to solve this problem (if it's solvable at all). It seems to me that, if a resize happens and the cursor gets pushed off-screen, then that will always trigger a scroll, which the application can detect and scroll the viewport back up and redraw the screen. The problem is this will introduce flickering as the application states before and after the resize will be separated by a third intermediary state in which the viewport was scrolled down. So far I see no way to have smooth, non-layout-breaking resizing if resizing can cause the viewport to scroll. So I have a couple questions:
- Is there a way to prevent this flickering from happening?
- If it is impossible to prevent auto scrolling when cursor is pushed off-screen, would always having the cursor at the next to last line and maybe polling frequently enough mitigate this issue?
- Couldn't an application just opt-out of this behavior. Maybe there could be a console mode that you could set to always have the cursor within the screen if the window is resized that would work only when an application switches to the alternate screen buffer.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by investigating how Windows Terminal handles terminal resizing when the cursor is pushed off-screen, including the resulting scroll and redraw sequence. Compare the three proposed approaches: preventing the flicker, keeping the cursor near the bottom, or providing an alternate-screen opt-out. Done means a feasible behavior is selected and its effect on resizing and redraws is demonstrated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100