Conhost "find and color" feature doesn't work with DBCS text #11797

Closed
opened 2026-01-31 02:57:47 +00:00 by claunia · 2 comments
Owner

Originally created by @j4james on GitHub (Dec 13, 2020).

Environment

Windows build number: Version 10.0.18363.1198
Windows Terminal version (if applicable):

Steps to reproduce

  1. Open a cmd shell in conhost.
  2. Output some text from a double byte character set (e.g. こんにちは).
  3. Output the same text with the characters repeated (e.g. ここんんににちちはは).
  4. Select an instance of the text from step 2.
  5. Press Ctrl+Shift+4 to search for matching text and color it in green.

Expected behavior

All the instances of text from step 2 should be colored in green.

image

Actual behavior

The search mistakenly matches the instances of text from step 3 (where the characters are repeated).

image

The problem is caused by the code that extracts the search text from the screen buffer here:

d09fdd61cb/src/host/selectionInput.cpp (L695-L701)

It's copying one screen cell at a time from the selected range, but that means each character is copied twice with DBCS text, since there are two cells per character.

Originally created by @j4james on GitHub (Dec 13, 2020). # Environment ```none Windows build number: Version 10.0.18363.1198 Windows Terminal version (if applicable): ``` # Steps to reproduce 1. Open a cmd shell in conhost. 2. Output some text from a double byte character set (e.g. `こんにちは`). 3. Output the same text with the characters repeated (e.g. `ここんんににちちはは`). 4. Select an instance of the text from step 2. 5. Press `Ctrl+Shift+4` to search for matching text and color it in green. # Expected behavior All the instances of text from step 2 should be colored in green. ![image](https://user-images.githubusercontent.com/4181424/102013009-4b484f80-3d45-11eb-84bb-60f907e549fc.png) # Actual behavior The search mistakenly matches the instances of text from step 3 (where the characters are repeated). ![image](https://user-images.githubusercontent.com/4181424/102013014-57341180-3d45-11eb-981b-143d5d581213.png) The problem is caused by the code that extracts the search text from the screen buffer here: https://github.com/microsoft/terminal/blob/d09fdd61cbb11b7ef2ccdd4820349ffe898ad583/src/host/selectionInput.cpp#L695-L701 It's copying one screen cell at a time from the selected range, but that means each character is copied twice with DBCS text, since there are two cells per character.
claunia added the Needs-TriageResolution-Fix-CommittedNeeds-Tag-Fix labels 2026-01-31 02:57:48 +00:00
Author
Owner

@j4james commented on GitHub (Dec 13, 2020):

Btw, if you're wondering why I care about these weird cases of undocumented functionality, it's because I'm trying to finish off a PR for #7865, and that touches on all of these areas. And I can't tell if my changes are working when the existing code is already broken. So I thought it best to get these fixes in place first, rather than bundling them into my PR which is complicated enough as it is.

@j4james commented on GitHub (Dec 13, 2020): Btw, if you're wondering why I care about these weird cases of undocumented functionality, it's because I'm trying to finish off a PR for #7865, and that touches on all of these areas. And I can't tell if my changes are working when the existing code is already broken. So I thought it best to get these fixes in place first, rather than bundling them into my PR which is complicated enough as it is.
Author
Owner

@ghost commented on GitHub (Jan 28, 2021):

:tada:This issue was addressed in #8577, which has now been successfully released as Windows Terminal Preview v1.6.10272.0.🎉

Handy links:

@ghost commented on GitHub (Jan 28, 2021): :tada:This issue was addressed in #8577, which has now been successfully released as `Windows Terminal Preview v1.6.10272.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.6.10272.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11797