Skip to content

Incorrect DECCRA behavior when copying from a double-width line #15019

@j4james

Description

@j4james

Windows Terminal version

1.17.1023

Windows build number

10.0.19044.2364

Other Software

No response

Steps to reproduce

  1. Open a WSL bash shell in Windows Terminal.

  2. Make sure the viewport width is around 80 columns.

  3. Execute the following command:

     printf "\e#8\e[8H\e[J\e[4H\e[41m\e#6\e[m\e[H\e[3;20;5;60;1;10;20;1\$v"
    

Expected Behavior

That test case is copying a block of text spanning a double-width row from the top to the bottom half of the screen. The copied block should look something like this (the gap is from the section of the double-width row that is off screen).

image

Actual Behavior

The copied block ends up looking like this:

image

This is a regression that was introduced in PR #14650 when I was trying to fix horizontal scrolling of DBCS characters. The copy operation reads two characters in advance, and the code that checks whether the source is off screen ends up using the cursor position from the wrong character.

This can be fixed by saving the current srcPos at the same time as we save the current OutputCell in the loop here:

const auto current = next;
srcView.WalkInBounds(srcPos, walkDirection);
next = OutputCell(*textBuffer.GetCellDataAt(srcPos));
// If the source position is offscreen (which can occur on double
// width lines), then we shouldn't copy anything to the destination.
if (srcPos.x < textBuffer.GetLineWidth(srcPos.y))
{
textBuffer.WriteLine(OutputCellIterator({ &current, 1 }), dstPos);
}

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-ConhostFor issues in the Console codebase

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions