Skip to content

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

Closed

Description

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.

Activity

  1. ghost added
    Needs-Triage
    on Dec 13, 2020
  2. ghost added
    Needs-Tag-Fix
    on Dec 13, 2020
  3. j4james commented on Dec 13, 2020

    @j4james
    CollaboratorAuthor

    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.

  4. ghost added
    In-PR
    on Dec 13, 2020
  5. ghost closed this as completedin #8577on Dec 14, 2020
  6. ghost added a commit that references this issue on Dec 14, 2020
  7. ghost removed
    In-PR
    on Dec 14, 2020
  8. ghost added
    Resolution-Fix-Committed
    on Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-Tag-FixNeeds-TriageResolution-Fix-Committed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions