Allowin thunks in eventHandlers. more progress on OS palette. adding fuzzy match to storeSearch
This commit is contained in:
parent
f378149146
commit
b8a396a734
6 changed files with 53 additions and 35 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue