-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
Environment
Windows build number: Version 10.0.18363.1198
Windows Terminal version (if applicable):
Steps to reproduce
- Open a cmd shell in conhost.
- Open the Properties dialog and make sure Enable line wrapping selection is turned on.
- Select a range of text wrapped across multiple lines.
- Press
Ctrl+4to highlight the selected text in green. - Output some text from double byte character set.
- Select a range of those characters starting and ending halfway through a double width character.
- Again press
Ctrl+4to highlight the selected text in green.
Expected behavior
When the selection wraps across multiple lines, the green highlighting should also wrap in exactly the same way. When selecting halfway through a double width character, the selection always covers the full width, so I'd expect the green highlighting to work in the same way.
Actual behavior
The wrapped selection changes to a block selection when painting the green background. And only half of the start and end characters in the DBCS range are painted green (I should note that this renders differently in the current openconsole build, but is still doesn't match the initial selection).
The reason for this behaviour is that the color selection code just uses a simple rect spanning the start and end points of the selection, where typically a selection operation should be using the Selection::GetSelectionRects method to obtain the affected range (which automatically handles the line wrapping option, and makes sure double width characters are fully covered).
The code I'm referring to is here:
terminal/src/host/selectionInput.cpp
Line 720 in d09fdd6
| ColorSelection(_srSelectionRect, selectionAttr); |
And my recommendation would be to change the line above to use the GetSelectionRects method like this:
const auto selectionRects = GetSelectionRects();
for (const auto& selectionRect : selectionRects)
{
ColorSelection(selectionRect, selectionAttr);
}I suppose it's possible the current behaviour is deliberate, but I think it's more likely it was just an oversight when conhost was updated to support wrapped selections.

