-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
Windows Terminal version
1.17.1023
Windows build number
10.0.19044.2364
Other Software
No response
Steps to reproduce
-
Open a WSL bash shell in Windows Terminal.
-
Make sure the viewport width is around 80 columns.
-
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).
Actual Behavior
The copied block ends up looking like this:
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:
terminal/src/terminal/adapter/adaptDispatch.cpp
Lines 1155 to 1163 in b9248fa
| 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({ ¤t, 1 }), dstPos); | |
| } |

