Skip to content

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

@j4james

Description

@j4james

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:

auto it = screenInfo.GetTextDataAt(COORD{ selectRect.Left, selectRect.Top });
for (SHORT i = 0; i < (selectRect.Right - selectRect.Left + 1); ++i)
{
str.append((*it).begin(), (*it).end());
it++;
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-Tag-FixDoesn't match tag requirementsNeeds-TriageIt's a new issue that the core contributor team needs to triage at the next triage meetingResolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions