Skip to content
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

Reflow behavior on window resize seems broken if the cursor is hidden #17151

Closed
kunom opened this issue Apr 28, 2024 · 5 comments · Fixed by #17510
Closed

Reflow behavior on window resize seems broken if the cursor is hidden #17151

kunom opened this issue Apr 28, 2024 · 5 comments · Fixed by #17510
Labels
Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Priority-3 A description (P3) Product-Conpty For console issues specifically related to conpty
Milestone

Comments

@kunom
Copy link

kunom commented Apr 28, 2024

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:

  1. 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)
  2. Start the script in a new, non-maximized window: start status.py
  3. Take your mouse and rapidly change the width of the window, so that content is repeatedly reflowed. See heavy display distortions:
    image
  4. 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:
    image

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?

@kunom kunom added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Apr 28, 2024
Copy link

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:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@carlos-zamora
Copy link
Member

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.

@carlos-zamora carlos-zamora added Product-Conpty For console issues specifically related to conpty Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 1, 2024
@carlos-zamora carlos-zamora added this to the Terminal v1.22 milestone May 1, 2024
@carlos-zamora carlos-zamora added the Priority-3 A description (P3) label May 1, 2024
@carlos-zamora carlos-zamora modified the milestones: Terminal v1.22, Backlog May 1, 2024
@kunom
Copy link
Author

kunom commented May 2, 2024

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"?

@salt-die
Copy link

salt-die commented Jul 5, 2024

Same issue with a much more complicated example:

Cursor shown and resizing no issue

2024-07-05.10-59-29.mp4

Cursor hidden and artifacts when resizing

2024-07-05.10-59-50.mp4

@lhecker
Copy link
Member

lhecker commented Jul 5, 2024

I tested this with #17510 and at least the initial 2 repros above seem to be fixed.

@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Aug 1, 2024
@lhecker lhecker closed this as completed in 450eec4 Aug 1, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Priority-3 A description (P3) Product-Conpty For console issues specifically related to conpty
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants