Skip to content

Conversation

@ThanhNguyxn
Copy link

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

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.

Add Unicode normalization to FuzzyStringMatcher.FoldCase() to properly
handle diacritical marks (accents, tildes, umlauts, etc.) in search
queries. This allows searching 'camera' to match 'Câmera' and similar
accented variations.

The fix uses FormKD normalization to decompose characters into base
characters and combining marks, then removes the combining marks
(NonSpacingMark category).

This brings Command Palette search behavior in line with PowerToys Run
and Settings search, which already handle diacritics correctly.

Closes microsoft#44066
Copilot AI review requested due to automatic review settings December 5, 2025 11:30
@ThanhNguyxn
Copy link
Author

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! 🙏

Copilot finished reviewing on behalf of ThanhNguyxn December 5, 2025 11:32
[TestMethod]
public void QueryMatchesAppsWithDiacritics()
{
// Arrange - simulating Brazilian Portuguese "Câmera" app

/// <summary>
/// Normalizes a string for fuzzy matching by converting to uppercase and removing diacritical marks.
/// This allows matching "camera" with "Câmera", "camêra", etc.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Command Palette's fuzzy string matching to handle diacritics (accented characters) properly, enabling searches like "camera" to match app names like "Câmera". The implementation follows the same normalization pattern already used in PowerToys Settings search.

Key changes:

  • Enhanced FuzzyStringMatcher.FoldCase() to normalize diacritics using Unicode decomposition (FormKD) and filtering of NonSpacingMark characters
  • Added comprehensive unit tests covering multiple languages (Portuguese, French, Spanish, German)
  • Updated spell-check dictionary to include "mera" from test case references

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/FuzzyStringMatcher.cs Updated FoldCase() method to normalize diacritics by decomposing Unicode characters and removing combining marks
src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Apps.UnitTests/QueryTests.cs Added two test methods: FuzzyMatcherHandlesDiacritics with 11 data-driven test cases and QueryMatchesAppsWithDiacritics for integration testing
.github/actions/spell-check/expect.txt Added "mera" to recognized terms for "Câmera" references in test code

@jiripolasek
Copy link
Collaborator

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?

@ThanhNguyxn
Copy link
Author

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

@michaeljolley michaeljolley added the Product-Command Palette Refers to the Command Palette utility label Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command palette not correctly handling diacritics in the apps/programs extension

3 participants