moving
Some checks failed
Installer Smoke / installer-smoke (push) Has been cancelled

This commit is contained in:
Oleg Maslov
2026-09-02 10:10:29 +02:00
commit 0c3e2ead3b
3841 changed files with 970576 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
/**
* Simple fuzzy matching — no external deps.
* Used by GlobalSearch (Ctrl+K).
*/
export interface FuzzyResult {
match: boolean;
score: number;
}
export function fuzzyMatch(query: string, text: string): FuzzyResult {
const q = query.toLowerCase();
const t = text.toLowerCase();
if (!q) return { match: true, score: 0 };
// Exact substring — highest score
const idx = t.indexOf(q);
if (idx >= 0) return { match: true, score: 100 - idx };
// Character-by-character fuzzy
let qi = 0;
let score = 0;
for (let ti = 0; ti < t.length && qi < q.length; ti++) {
if (t[ti] === q[qi]) {
score += (ti === 0 || t[ti - 1] === ' ' || t[ti - 1] === '/' || t[ti - 1] === '-') ? 10 : 1;
qi++;
}
}
return { match: qi === q.length, score };
}