Fix: minor

This commit is contained in:
eight 2018-10-13 15:03:10 +08:00
parent 43afa31fa0
commit d60db9dbef

View File

@ -44,34 +44,29 @@
icase = words.some(w => w === lower(w)); icase = words.some(w => w === lower(w));
} }
const results = []; return styleManager.getAllStyles().then(styles => {
return styleManager.getAllStyles() if (ids) {
.then(styles => { const idSet = new Set(ids);
if (ids) { styles = styles.filter(s => idSet.has(s.id));
const idSet = new Set(ids); }
return styles.filter(s => idSet.has(s.id)); const results = [];
for (const style of styles) {
const id = style.id;
if (!query || words && !words.length) {
results.push(id);
continue;
} }
return styles; for (const part in PARTS) {
}) const text = style[part];
.then(styles => { if (text && PARTS[part](text, rx, words, icase)) {
for (const style of styles) {
const id = style.id;
if (!query || words && !words.length) {
results.push(id); results.push(id);
continue; break;
}
for (const part in PARTS) {
const text = style[part];
if (text && PARTS[part](text, rx, words, icase)) {
results.push(id);
break;
}
} }
} }
}
if (cache.size) debounce(clearCache, 60e3); if (cache.size) debounce(clearCache, 60e3);
return results; return results;
}); });
}; };
function searchText(text, rx, words, icase) { function searchText(text, rx, words, icase) {