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

Cursor movement is not always detected on double-width lines #17232

Closed
j4james opened this issue May 9, 2024 · 1 comment · Fixed by #17233
Closed

Cursor movement is not always detected on double-width lines #17232

j4james opened this issue May 9, 2024 · 1 comment · Fixed by #17233
Labels
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

Comments

@j4james
Copy link
Collaborator

j4james commented May 9, 2024

Windows Terminal version

1.21.1272.0

Windows build number

10.0.19045.4291

Other Software

No response

Steps to reproduce

  1. Open a WSL bash shell in Window Terminal
  2. Execute the following statement:
    printf "\e[2 q\e#6\e[11G"; for i in {1..10}; do printf "\e[D"; sleep 1; done
    

Expected Behavior

This starts by setting the cursor style to a steady block so it's easy to see, then positions the cursor in column 11 and moves it left by 1 column every second until it reaches column 1.

Actual Behavior

When it gets to column 3 is pauses for 2 seconds before jumping to column 1. You never see the cursor in column 2.

This is because of the way conpty determines whether the cursor has moved in the InvalidateCursor method here:

_cursorMoved = psrRegion->origin() != _lastText;

The psrRegion is in screen coordinates, while the _lastText position in buffer coordinates. So on a double-width line, when moving from column 3 to column 2, the _lastText column is 3, and the psrRegion->origin is also 3, because buffer column 2 spans screen columns 3 and 4. Thus it seems like no movement has occurred.

This was another bug introduced by PR #17194.

@j4james j4james 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 May 9, 2024
Copy link

github-actions bot commented May 9, 2024

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!

Open similar issues:

Closed similar issues:

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

github-merge-queue bot pushed a commit that referenced this issue May 10, 2024
When the VT render engine checks whether the cursor has moved in the
`InvalidateCursor` method, it does so by comparing the origin of the
given cursor region with the last text output coordinates. But these two
values are actually from different coordinate systems, and when on a
double-width line, the x text coordinate is half of the corresponding
screen coordinate. As a result, the movement detection is sometimes
incorrect.

This PR fixes the issue by adding another field to track the last cursor
origin in screen coordinates, so we have a meaningful value to compare
against.

## References and Relevant Issues

The previous cursor movement detection was added in PR #17194 to fix
issue #17117.

## Validation Steps Performed

I've confirmed that the test case from issue #17232 is now fixed, and
the test case from issue #17117 is still working as expected.

## PR Checklist
- [x] Closes #17232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant