PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Fix Command Palette not handling diacritics in apps search

Open ThanhNguyxn opened this issue 3 weeks ago • 4 comments

Summary of the Pull Request

Fixes Command Palette not correctly handling diacritics (accented characters) in the apps/programs extension search.

Note: This is a re-open of #44070 which was accidentally closed when the branch was deleted.

PR Checklist

  • [x] Closes #44066
  • [x] Communication: I've discussed this with core contributors already.
  • [x] Tests: Added/passed
  • [x] Localization: N/A
  • [x] Documentation: N/A
  • [x] Dev docs: N/A

Problem

When searching for apps in Command Palette, queries without diacritics would not match app names containing diacritical marks:

  • Searching "camera" would NOT find the app "Câmera" ❌
  • Searching "câmera" would find the app "Câmera" ✅

This was inconsistent with PowerToys Run and Settings search, which both handle diacritics correctly.

Solution

Updated FuzzyStringMatcher.FoldCase() to normalize diacritics using Unicode decomposition:

private static string FoldCase(string input)
{
    var upper = input.ToUpperInvariant();
    
    // Normalize to decomposed form (separates base characters from combining marks)
    var normalized = upper.Normalize(NormalizationForm.FormKD);
    
    // Remove combining marks (diacritical marks like accents, tildes, etc.)
    var sb = new StringBuilder(normalized.Length);
    foreach (var c in normalized)
    {
        if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)
        {
            sb.Append(c);
        }
    }
    return sb.ToString();
}

Now both query and target are normalized, allowing diacritic-insensitive matching.

ThanhNguyxn avatar Dec 05 '25 11:12 ThanhNguyxn

Note to Maintainers

I apologize for the confusion - the original PR #44070 was accidentally closed when the source branch was deleted during a branch cleanup operation on my fork.

This PR contains the exact same changes as #44070, rebased onto the latest main. The fix has already been reviewed and approved by @htcfreek in the original PR.

Sorry for any inconvenience this may have caused. Thank you for your patience! 🙏

ThanhNguyxn avatar Dec 05 '25 11:12 ThanhNguyxn

Note to Maintainers

I apologize for the confusion - the original PR #44070 was accidentally closed when the source branch was deleted during a branch cleanup operation on my fork.

This PR contains the exact same changes as #44070, rebased onto the latest main. The fix has already been reviewed and approved by @htcfreek in the original PR.

Sorry for any inconvenience this may have caused. Thank you for your patience! 🙏

Hi @htcfreek, sorry to bother you. Do you know anything about this?

jiripolasek avatar Dec 05 '25 17:12 jiripolasek

I apologize for incorrectly mentioning @htcfreek in my previous comment - they were not involved in reviewing the original PR #44070. Sorry for the confusion!

ThanhNguyxn avatar Dec 06 '25 03:12 ThanhNguyxn

@ThanhNguyxn please walk me through with screenshots how this was tested and verified on your end.

crutkas avatar Dec 07 '25 20:12 crutkas

#44090 looks like an objectively better way to address this issue. We should probably move in that direction, rather than introduce more allocations.

zadjii-msft avatar Dec 09 '25 14:12 zadjii-msft