#386·cmdk

Remove unicode diacritics in default filter function

Author: davbritoCreated Oct 6, 2025Updated Feb 6, 2026

Suggestion

Currently, the search string normalization in cmdk/src/command-score.ts only performs lowercasing and space character replacement:

typescript
function formatInput(string) {
  // convert all valid space characters to space so they match each other
  return string.toLowerCase().replace(COUNT_SPACE_REGEXP, ' ')
}

This approach does not handle unicode diacritics (e.g., accents in café, naïve, etc.). As a result, searches for "cafe" will not match "café".

Proposal:

Extend search string normalization to remove unicode diacritics using String.prototype.normalize('NFD') and a regex to strip combining marks:

typescript
function formatInput(string) {
  return string
    .toLowerCase()
    .normalize('NFD') // Decompose unicode characters
    .replace(/[\u0300-\u036f]/g, '') // Remove diacritical marks
    .replace(COUNT_SPACE_REGEXP, ' ')
}

This change will make search matching more robust for international users and improve search results for text containing diacritics.

Location: