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

Open
opened 2026-01-31 02:57:40 +00:00 by claunia · 0 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:40 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11792