Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Reporter: Faster and fuzzier module dropdown filter #1685

Merged
merged 1 commit into from
Apr 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/html-reporter/html.js
Expand Up @@ -466,7 +466,7 @@ export function escapeText (s) {
if (searchText === '') {
items = moduleSearchCache.map(obj => obj.item);
} else {
items = fuzzysort.go(searchText, moduleSearchCache, { key: 'name', threshold: -10000 })
items = fuzzysort.go(searchText, moduleSearchCache, { key: 'name', allowTypo: true })
.map(result => result.obj.item);
}
const fragment = document.createDocumentFragment();
Expand All @@ -479,11 +479,15 @@ export function escapeText (s) {
// Processes module search box input
let searchInputTimeout;
function searchInput () {
// Use a debounce with a ~0ms timeout. This is effectively instantaneous,
// but is better than undebounced because it avoids an ever-growing
// backlog of unprocessed now-outdated input events if fuzzysearch or
// drodown DOM is slow (e.g. very large test suite).
window.clearTimeout(searchInputTimeout);
searchInputTimeout = window.setTimeout(() => {
dropDownList.innerHTML = '';
dropDownList.appendChild(filterModules(moduleSearch.value));
}, 200);
});
}

// Processes selection changes
Expand Down