Skip to content

Conpty cursor mispositioned when using double width lines #15014

@j4james

Description

@j4james

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-VTVirtual Terminal sequence supportHelp WantedWe encourage anyone to jump in on these.In-PRThis issue has a related PRIssue-BugIt either shouldn't be doing this or needs an investigation.Needs-Tag-FixDoesn't match tag requirementsProduct-ConptyFor console issues specifically related to conpty

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions