Skip to content

Fix color selection operations in conhost - #8577

Merged
2 commits merged into
microsoft:mainfrom
j4james:fix-color-selection
Dec 14, 2020
Merged

2 commits merged into
microsoft:mainfrom
j4james:fix-color-selection

Conversation

@j4james

@j4james James Holderness (j4james) commented Dec 13, 2020 •

Copy link
Copy Markdown
Collaborator

In conhost there is a keyboard shortcut that applies colors to the
selected range of text, and another shortcut that searches for the
selected text, and applies colors to any matching content. The former
operation doesn't work correctly when the selection is wrapped, and both
have problems when the selected text spans DBCS characters. This PR
attempts to fix those issues.

The problem with the color section was that it applied the color to a
simple rect spanning the start and end points of the selection. I've now
updated it to use the Selection::GetSelectionRects method, which
correctly handles a wrapped range of lines, and makes sure that double
width characters are fully covered.

The problem with the "find-and-color" operation was in the way it
obtained the search text from the selected screen cells. Since it
retrieved one cell at a time, and a DBCS character can span two cells,
that resulted in some characters being repeated in the search text. I've
now corrected that code to take the width of the characters into
account.

Validation Steps Performed

I've manually verified that the test cases described in #8572 and #8574
are now working correctly.

Closes #8572
Closes #8574

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Thanks again for the attention to detail 😄

@DHowett Dustin L. Howett (DHowett) added the AutoMerge Marked for automatic merge by the bot when requirements are met label Dec 14, 2020
@ghost

Copy link
Copy Markdown

Hello Dustin L. Howett (@DHowett)!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost
ghost merged commit cae0f9a into microsoft:main Dec 14, 2020
@miniksa

Copy link
Copy Markdown
Contributor

Good call. Thank you.

@j4james
James Holderness (j4james) deleted the fix-color-selection branch December 19, 2020 00:36
@ghost

Copy link
Copy Markdown

🎉Windows Terminal Preview v1.6.10272.0 has been released which incorporates this pull request.:tada:

Handy links:

MPela (mpela81) pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
In conhost there is a keyboard shortcut that applies colors to the
selected range of text, and another shortcut that searches for the
selected text, and applies colors to any matching content. The former
operation doesn't work correctly when the selection is wrapped, and both
have problems when the selected text spans DBCS characters. This PR
attempts to fix those issues.

The problem with the color section was that it applied the color to a
simple rect spanning the start and end points of the selection. I've now
updated it to use the `Selection::GetSelectionRects` method, which
correctly handles a wrapped range of lines, and makes sure that double
width characters are fully covered.

The problem with the "find-and-color" operation was in the way it
obtained the search text from the selected screen cells. Since it
retrieved one cell at a time, and a DBCS character can span two cells,
that resulted in some characters being repeated in the search text. I've
now corrected that code to take the width of the characters into
account.

## Validation Steps Performed
I've manually verified that the test cases described in microsoft#8572 and microsoft#8574
are now working correctly.

Closes microsoft#8572
Closes microsoft#8574
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AutoMerge Marked for automatic merge by the bot when requirements are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conhost "find and color" feature doesn't work with DBCS text Conhost color selection doesn't work correctly with wrapping and DBCS

4 participants