terminal
terminal copied to clipboard
Reflow behavior on window resize seems broken if the cursor is hidden
Windows Terminal version
1.19.10821.0
Windows build number
10.0.19045.4291
Other Software
No response
Steps to reproduce
I have a strange reflow bug that seems to occur only when the cursor is hidden. Steps to reproduce:
- Paste the following Python code into a file named
status.py
:import time HIDE_CURSOR = "\x1b[?25l" LF_AND_CLEAR_LINE = "\r\x1b[2K" print("foo " * 100) print() print(HIDE_CURSOR) # --> removing this line fixes the issue for i in range(100000): print(f"{LF_AND_CLEAR_LINE}working {i}...", end="", flush=True) time.sleep(0.05)
- Start the script in a new, non-maximized window:
start status.py
- Take your mouse and rapidly change the width of the window, so that content is repeatedly reflowed. See heavy display distortions:
- In the script, remove the "hide cursor" statement and redo the test. Everything works fine now, regardless how heavy you try to distort the display:
Expected Behavior
The reflow mechanism should work regardless of whether the cursor is rendered or not. The behaviour with the visible cursor is the correct one.
Actual Behavior
It looks as if the display reflow logic is broken when the cursor is not rendered, maybe the full line inclusive trailing whitespace is reflowed?
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Closed similar issues:
- Cursor position is lost when resizing the window horizontally (#10868), similarity score: 0.75
- Resizing the terminal window results in glitchy text-rendering behavior. (Duplicate #3088) (#7242), similarity score: 0.75
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Version | Repro? |
---|---|
1.20.10822 | ✅ |
1.19.10821 | ✅ |
1.18.3181 | ✅, but not as badly |
Looks like this script doesn't enable VIRTUAL_TERMINAL_PROCESSING mode before printing control sequences. This isn't the root cause but it will cause problems down the line.
My example script is a stripped-down version of using the rich package, which seems to be widely adopted and is even referenced by the pip
module.
import rich.status
import time
with rich.status.Status("working..."):
time.sleep(10000)
rich
somehow cares about ENABLE_VIRTUAL_TERMINAL_PROCESSING
and the console mode, but only queries it and never calls SetConsoleMode()
.
What sort of issues do you have in mind when talking about "problems down the line"?
Same issue with a much more complicated example:
Cursor shown and resizing no issue
https://github.com/microsoft/terminal/assets/53280662/1d3792a3-cfe3-48a2-bc07-c8c17e98917e
Cursor hidden and artifacts when resizing
https://github.com/microsoft/terminal/assets/53280662/fb6b47d3-a26f-4616-aea4-1f01092d6401
I tested this with #17510 and at least the initial 2 repros above seem to be fixed.