fix(settings): require all query words to match (#1665)

Signed-off-by: liamt8d <[email protected]>
Co-authored-by: Hampus <[email protected]>
This commit is contained in:
Liam
2026-08-16 00:44:34 +02:00
committed by GitHub
co-authored by Hampus
parent 1bced6abae
commit 358b7c88fc
@@ -168,16 +168,27 @@ function calculateKeywordMatchScore(keywords: Array<string>, word: string): numb
function calculateMatchScore(item: SearchableSettingItem, queryWords: Array<string>): number {
let score = 0;
const labelLower = item.label.toLowerCase();
const descriptionLower = item.description?.toLowerCase() ?? '';
const keywordsLower = [...item.keywords, ...(item.tags ?? [])].map((k) => k.toLowerCase());
const keywordsLower = [...item.keywords, ...(item.tags ?? [])].map((value) => value.toLowerCase());
for (const word of queryWords) {
score += calculateTextMatchScore(labelLower, word, 100, 50, 25);
score += calculateKeywordMatchScore(keywordsLower, word);
let wordScore = calculateTextMatchScore(labelLower, word, 100, 50, 25);
wordScore += calculateKeywordMatchScore(keywordsLower, word);
if (descriptionLower.includes(word)) {
score += 10;
wordScore += 10;
}
if (wordScore === 0) {
return 0;
}
score += wordScore;
}
return score;
}