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

Open
opened 2026-01-31 06:47:17 +00:00 by claunia · 0 comments
Owner

Originally created by @j4james on GitHub (Mar 19, 2023).

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:

b9248fa903/src/terminal/adapter/adaptDispatch.cpp (L1155-L1163)

Originally created by @j4james on GitHub (Mar 19, 2023). ### 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](https://user-images.githubusercontent.com/4181424/226184467-91e4efb4-29be-4faf-9c75-26f398d44f22.png) ### Actual Behavior The copied block ends up looking like this: ![image](https://user-images.githubusercontent.com/4181424/226184696-f162812b-91b1-4164-b1a0-022947276e65.png) 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: https://github.com/microsoft/terminal/blob/b9248fa903eaa8d187c72bf08f8aa17b25f9d6bb/src/terminal/adapter/adaptDispatch.cpp#L1155-L1163
claunia added the Help WantedProduct-ConhostIssue-BugIn-PRArea-VTNeeds-Tag-Fix labels 2026-01-31 06:47:18 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19561