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

Conpty cursor mispositioned when using double width lines #15014

Closed
j4james opened this issue Mar 18, 2023 · 0 comments · Fixed by #17510
Closed

Conpty cursor mispositioned when using double width lines #15014

j4james opened this issue Mar 18, 2023 · 0 comments · Fixed by #17510
Labels
Area-VT Virtual Terminal sequence support Help Wanted We encourage anyone to jump in on these. 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 Product-Conpty For console issues specifically related to conpty
Milestone

Comments

@j4james
Copy link
Collaborator

j4james commented Mar 18, 2023

Windows Terminal version

1.17.1023

Windows build number

10.0.19044.2364

Other Software

No response

Steps to reproduce

  1. Start a bash shell in Windows Terminal.
  2. Make sure your screen width is an even number of columns.
  3. Execute clear to make sure he screen is cleared.
  4. Execute printf "\e#6\e[999Cv\e#5\n\e#6\e[999C*\e[B^\n"

Expected Behavior

The v and ^ characters should be in the same column, looking something like this:

image

Actual Behavior

The ^ character is one column to the left of v.

image

I'm almost sure this used to work in the past, so I suspect this might be fallout from one of the delayed EOL wrap fixes (possibly PR #14640 or PR #14936).

What's happening is the * is written at the end of a double-width line, so the cursor sets the delayed wrap flag, but doesn't move forward. However, conpty doesn't recognise that state, so it thinks the cursor is one column to the right of where it really is. Then when it needs to move down a row to output the ^, it uses a backspace to adjust the column offset, but that adjustment wasn't needed, so the ^ ends up in the wrong column.

I think the easiest fix for this would be to disable the conpty cursor optimisations whenever we've got double-width lines renditions on the page. That just requires adding the _usingLineRenditions flag to the condition here:

else if (_delayedEolWrap)
{
// GH#1245, GH#357 - If we were in the delayed EOL wrap state, make
// sure to _manually_ position the cursor now, with a full CUP
// sequence, don't try and be clever with \b or \r or other control
// sequences. Different terminals (conhost, gnome-terminal, wt) all
// behave differently with how the cursor behaves at an end of line.
// This is the only solution that works in all of them, and also
// works wrapped lines emitted by conpty.
//
// Make sure to do this _after_ the possible \r\n branch above,
// otherwise we might accidentally break wrapped lines (GH#405)
hr = _CursorPosition(coord);
}

@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 Mar 18, 2023
@zadjii-msft zadjii-msft added Help Wanted We encourage anyone to jump in on these. Area-VT Virtual Terminal sequence support and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Mar 20, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Mar 20, 2023
@zadjii-msft zadjii-msft added the Product-Conpty For console issues specifically related to conpty label Mar 20, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 20, 2023
@zadjii-msft zadjii-msft added this to the Backlog milestone Mar 20, 2023
@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-VT Virtual Terminal sequence support Help Wanted We encourage anyone to jump in on these. 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 Product-Conpty For console issues specifically related to conpty
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants