Skip to content

Commit

Permalink
feat: Match characters with accents when no accents are entered (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed Dec 29, 2024
1 parent d6eab18 commit badfcf9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/popup/baseItemList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import { cmdOrCtrlKey } from "../common/util.js";

const DIACRITICS = /[\u0300-\u036f]/g;

export default class BaseItemList extends HTMLElement {
#pendingSearch;
#pendingSearchTimeout;
Expand Down Expand Up @@ -505,13 +507,20 @@ export default class BaseItemList extends HTMLElement {
let selectNode = null;

let lowerSearchTerm = this.searchValue.toLowerCase();
let hasAccent = !!lowerSearchTerm.normalize("NFD").match(DIACRITICS);

this.#clearItems();

if (lowerSearchTerm) {
let searchWords = lowerSearchTerm.split(/\s+/);

for (let item of this.allItems) {
let itemText = this.getItemText(item).toLowerCase();

if (!hasAccent) {
itemText = itemText.normalize("NFD").replace(DIACRITICS, "");
}

let mismatch = false;
for (let word of searchWords) {
if (word && !itemText.includes(word)) {
Expand Down

0 comments on commit badfcf9

Please sign in to comment.