diff --git a/src/components/treemode/TreeMode.svelte b/src/components/treemode/TreeMode.svelte index c1733fd..5d5a188 100644 --- a/src/components/treemode/TreeMode.svelte +++ b/src/components/treemode/TreeMode.svelte @@ -125,8 +125,9 @@ findRootPath searchHandler = searchAsync(searchText, doc, { onProgress: handleSearchProgressDebounced, - onDone: handleSearchDone - }, 10000, MAX_SEARCH_RESULTS) + onDone: handleSearchDone, + maxResults: MAX_SEARCH_RESULTS + }) } const history = createHistory({ diff --git a/src/logic/search.js b/src/logic/search.js index 176a706..5b6ecf4 100644 --- a/src/logic/search.js +++ b/src/logic/search.js @@ -109,7 +109,7 @@ async function tick () { } // TODO: comment -export function searchAsync (searchText, doc, { onProgress, onDone }, yieldAfterItemCount = 10_000, maxResults = Infinity) { +export function searchAsync (searchText, doc, { onProgress, onDone, maxResults = Infinity, yieldAfterItemCount = 10_000 }) { // TODO: what is a good value for yieldAfterItemCount? (larger means faster results but also less responsive during search) const search = searchGenerator(searchText, doc, yieldAfterItemCount) diff --git a/src/logic/search.test.js b/src/logic/search.test.js index bd9eced..964e4cf 100644 --- a/src/logic/search.test.js +++ b/src/logic/search.test.js @@ -63,7 +63,7 @@ describe('search', () => { } const yieldAfterItemCount = 1 - searchAsync('4', doc, { onProgress, onDone }, yieldAfterItemCount) + searchAsync('4', doc, { onProgress, onDone, yieldAfterItemCount }) // should not have results right after creation, but only on the first next tick assert.deepStrictEqual(callbacks, []) @@ -83,7 +83,7 @@ describe('search', () => { } const yieldAfterItemCount = 1 // very low so we can see whether actually cancelled - const { cancel } = searchAsync('4', doc, { onProgress, onDone }, yieldAfterItemCount) + const { cancel } = searchAsync('4', doc, { onProgress, onDone, yieldAfterItemCount }) setTimeout(() => { cancel() @@ -105,7 +105,7 @@ describe('search', () => { } const maxResults = 10 - searchAsync('item', doc, { onDone }, 1000, maxResults) + searchAsync('item', doc, { onDone, maxResults }) }) it('should generate recursive search results from flat results', () => {