Skip to content

Conversation

@DHowett
Copy link
Member

@DHowett DHowett commented Jul 23, 2025

The bulk of this work is changing Command::Name (and its descendants like GenerateName) to support looking up names in English and in the local language.

image image

Refs #19130, #19131, #19132, #19165
Closes #7039

Comment on lines 20 to 25
static bool shouldShowSubtitles = [] {
auto ctx = winrt::Windows::ApplicationModel::Resources::Core::ResourceContext::GetForViewIndependentUse();
auto qv = ctx.QualifierValues();
auto lang = qv.TryLookup(L"language");
return lang != L"en-US";
}();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't love this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's not great. This is actually another great example for what I said in my talk last week: If your base functions have bad performance you end up writing boilerplate caching logic to work around it everywhere. This is exactly that.

In any case, should this use til::starts_with_insensitive_ascii("en-")? 🤔

auto itemSubtitle = _Item.Subtitle();
int32_t subtitleWeight = 0;
std::tie(subtitleSegments, subtitleWeight) = _matchedSegmentsAndWeight(_pattern, itemSubtitle);
weight += subtitleWeight;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OPEN DISCUSSION (cc @e82eric) how do we combine weights when we have multiple haystacks

Copy link
Contributor

@e82eric e82eric Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the localization use case, looking at the screenshots, I would lean towards using the max of the 2 scores. I think where "split" gets matched in both the localized and English haystacks adding them would cause the items with English chars/matches in the localized version to score unfairly high compared to the ones that don't.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent excellent call. I've done this :)

@DHowett DHowett force-pushed the dev/duhowett/multi-lingual-command-palette branch from 703afff to 497b8f2 Compare July 23, 2025 23:16
@DHowett DHowett force-pushed the dev/duhowett/command-name-resource-or-string branch from 996b06c to e867912 Compare July 23, 2025 23:16
Base automatically changed from dev/duhowett/command-name-resource-or-string to main July 24, 2025 17:53
@DHowett DHowett marked this pull request as ready for review July 24, 2025 17:53
@DHowett DHowett force-pushed the dev/duhowett/multi-lingual-command-palette branch from df38587 to 38b9a7d Compare July 24, 2025 17:56
@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Area-CmdPal Command Palette issues and features Area-Localization Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Priority-1 A description (P1) Product-Terminal The new Windows Terminal. labels Jul 24, 2025
Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question. Otherwise LGTM.

Comment on lines 20 to 25
static bool shouldShowSubtitles = [] {
auto ctx = winrt::Windows::ApplicationModel::Resources::Core::ResourceContext::GetForViewIndependentUse();
auto qv = ctx.QualifierValues();
auto lang = qv.TryLookup(L"language");
return lang != L"en-US";
}();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's not great. This is actually another great example for what I said in my talk last week: If your base functions have bad performance you end up writing boilerplate caching logic to work around it everywhere. This is exactly that.

In any case, should this use til::starts_with_insensitive_ascii("en-")? 🤔

}

winrt::hstring CopyTextArgs::GenerateName() const
winrt::hstring CopyTextArgs::GenerateName(bool localized) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading this makes me realize that a localization system should probably pass the context of the localization (i.e. the locale) as a parameter to make the translation function pure. I should probably do the same for Edit...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to do that correctly, we should need to use ResourceContext directly. I am willing to make that change, but it is much more complicated than the one we have.

@e82eric
Copy link
Contributor

e82eric commented Jul 28, 2025

One thing I keep wondering on this, is how useful the subtitles are for locales that only have a couple of difficult to type chars (non Latin script languages?). I think there might be some cases like the user is typing something in Spanish and gets a result from a match on the English subtitle that they didn't expect.

It might be worth logging a future improvement to this to only show the subtitles for non Latin script languages (CJK, Cyrillic, Arabic, etc.) and then add the normalization logic into the fzf code to help with the non English Latin script languages.

This is probably a rare edge case, but thought it would be worth asking.

@DHowett
Copy link
Member Author

DHowett commented Jul 28, 2025

I think it's less about things which are hard to type, and more about having a common language -- it's easy to search a command palette using terms you find in documentation (for example) written in English and scattered about the web.

@e82eric
Copy link
Contributor

e82eric commented Jul 28, 2025

ahh, got it, that makes sense.

@DHowett
Copy link
Member Author

DHowett commented Jul 28, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DHowett DHowett enabled auto-merge (squash) July 28, 2025 18:57
@DHowett DHowett disabled auto-merge July 28, 2025 18:57
@DHowett DHowett enabled auto-merge (squash) July 28, 2025 18:58
@DHowett DHowett merged commit 65788d9 into main Jul 28, 2025
17 of 19 checks passed
@DHowett DHowett deleted the dev/duhowett/multi-lingual-command-palette branch July 28, 2025 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-CmdPal Command Palette issues and features Area-Localization Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Priority-1 A description (P1) Product-Terminal The new Windows Terminal.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't localize command names on the command palette

4 participants