Allowin thunks in eventHandlers. more progress on OS palette. adding fuzzy match to storeSearch

This commit is contained in:
Dustin Swan 2026-02-09 17:38:35 -07:00
parent f378149146
commit b8a396a734
No known key found for this signature in database
GPG key ID: 30D46587E2100467
6 changed files with 53 additions and 35 deletions

View file

@ -35,15 +35,17 @@ export const _rt = {
}
return text.length * 10; // fallback
},
storeSearch: (query: string) => {
const results: string[] = [];
const searchTerm = query.toLowerCase();
for (const name of Object.keys(store)) {
if (searchTerm === '' || name.toLowerCase().includes(searchTerm)) {
results.push(name);
}
fuzzyMatch: (query: string) => (target: string) => {
const q = query.toLowerCase();
const t = target.toLowerCase();
let qi = 0;
for (let ti = 0; ti < t.length && qi < q.length; ti++) {
if (t[ti] === q[qi]) qi++;
}
return results;
return { _tag: qi === q.length ? 'True' : 'False' };
},
storeSearch: (query: string) => {
return Object.keys(store).filter(name => _rt.fuzzyMatch(query)(name)._tag === 'True');
},
getSource: (name: string) => {
const ast = definitions.get(name);