Skip to content

CmdPal: Icon doesn't recognize grapheme clusters #41489

@jiripolasek

Description

@jiripolasek

Microsoft PowerToys version

0.93.0

Installation method

PowerToys auto-update

Area(s) with issue?

Command Palette

Steps to reproduce

winrt::Microsoft::Terminal::UI::implementation::IconPathConverter and Microsoft.CmdPal.UI.Controls.IconBox treat anything longer than 2 UTF-16 code units as “not an emoji,” so multi-codepoint emoji/grapheme clusters get ignored. The check looks like this:

// If we fail to set the icon source using the "icon" as a path,
// let's try it as a symbol/emoji.
//
// Anything longer than 2 wchar_t's _isn't_ an emoji or symbol, so
// don't do this if it's just an invalid path.
if (!iconSource && iconPath.size() <= 2)
{
try
{
typename FontIconSource<TIconSource>::type icon;
const auto ch = til::at(iconPath, 0);

if (iconData is not null &&
@this.Source is FontIconSource)
{
if (!string.IsNullOrEmpty(iconData.Icon) && iconData.Icon.Length <= 2)
{
var ch = iconData.Icon[0];

Why this breaks:

Lots of emoji are grapheme clusters (multiple code points), e.g. family emojis, skin tones, gendered professions (🧙‍♂️ “man mage”), flags, etc.

E.g. 🧙‍♂️ has 4 codepoints: U+1F9D9 U+200D U+2642 U+FE0F

Those are a single user-perceived character but >2 wchar_ts, so they fail the length check.

https://github.com/microsoft/terminal/blob/main/src/types/CodepointWidthDetector.cpp

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugSomething isn't workingProduct-Command PaletteRefers to the Command Palette utilityResolution-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