diff options
| author | Stephen Blott | 2015-05-14 12:29:32 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-14 12:29:36 +0100 |
| commit | 4189ad2c17f430c1f64a9489d56e4167c79b0459 (patch) | |
| tree | 2bceefee6f34084d199b29cf4edeb4aaf8c1e2e4 /background_scripts | |
| parent | 5134a7a2befb0448c1a7e989f31530fd2e10df52 (diff) | |
| download | vimium-4189ad2c17f430c1f64a9489d56e4167c79b0459.tar.bz2 | |
Search completion; add additional filtering stage.
Two things:
1. Do not fire off requests to completion engines if the relevancy
score they are assigned wouldn't be enough to be included.
2. Fix off-by-one error in prepareSuggestions.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/completion.coffee | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 1e22587f..5755bfaf 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -513,7 +513,15 @@ class SearchEngineCompleter # continuation. onComplete suggestions, filter: filter - continuation: (onComplete) => + continuation: (suggestions, onComplete) => + # Fetch completion suggestions from suggestion engines. + + # We can skip this if any new suggestions we propose cannot score highly enough to make the list + # anyway. + if 10 <= suggestions.length and relevancy < suggestions[suggestions.length-1].relevancy + console.log "skip (cannot make the grade):", suggestions.length, query if SearchEngineCompleter.debug + return onComplete [] + CompletionSearch.complete searchUrl, queryTerms, (suggestions = []) => console.log "fetched suggestions:", suggestions.length, query if SearchEngineCompleter.debug onComplete suggestions.map mkSuggestion @@ -572,7 +580,7 @@ class MultiCompleter if shouldRunContinuations jobs = new JobRunner continuations.map (continuation) -> (callback) -> - continuation (newSuggestions) -> + continuation suggestions, (newSuggestions) -> suggestions.push newSuggestions... callback() @@ -602,7 +610,7 @@ class MultiCompleter for suggestion in suggestions url = suggestion.shortenUrl() continue if seenUrls[url] - break if ++count == @maxResults + break if count++ == @maxResults seenUrls[url] = suggestion # Generate HTML for the remaining suggestions and return them. |
