diff options
| author | Stephen Blott | 2015-05-10 08:59:14 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2015-05-10 11:44:05 +0100 | 
| commit | 5191ee986615f45bfaedb389e3b34fd0a1ce9ca9 (patch) | |
| tree | e0e2456c81527b35a00280ad51db5a1159381385 | |
| parent | 146957c9dae54c31ce4676b5a4b60a0000c05487 (diff) | |
| download | vimium-5191ee986615f45bfaedb389e3b34fd0a1ce9ca9.tar.bz2 | |
Search completion; reuse previous query.
| -rw-r--r-- | background_scripts/completion_engines.coffee | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index 51799971..729c68b0 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -213,6 +213,21 @@ CompletionEngines =      return null if returnResultsOnlyFromCache +    if @mostRecentQuery? and @mostRecentSuggestions? +      # If the user appears to be typing a continuation of the characters in all of the most recent query, +      # then we can re-use the results of the previous query. +      reusePreviousSuggestions = do (query) => +        query = queryTerms.join(" ").toLowerCase() +        return false unless 0 == query.indexOf @mostRecentQuery.toLowerCase() +        previousSuggestions = @mostRecentSuggestions.map (s) -> s.toLowerCase() +        return false unless query.length <= Utils.longestCommonPrefix previousSuggestions +        true + +      if reusePreviousSuggestions +        console.log "reuse previous query", @mostRecentQuery if @debug +        @mostRecentQuery = queryTerms.join " " +        return callback @completionCache.set completionCacheKey, @mostRecentSuggestions +      fetchSuggestions = (engine, callback) =>        url = engine.getUrl queryTerms        query = queryTerms.join(" ").toLowerCase() | 
