diff options
| author | Stephen Blott | 2015-05-10 13:03:32 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2015-05-10 14:14:02 +0100 | 
| commit | 09b2aad039c7894c6023100d03c9941649843b77 (patch) | |
| tree | 52a4f2f1f1fbdab2cb93e0f7e5c95b490498d10c /background_scripts/completion_engines.coffee | |
| parent | 9bc1c215e3857d109fca2a073fd50799e0021cc8 (diff) | |
| download | vimium-09b2aad039c7894c6023100d03c9941649843b77.tar.bz2 | |
Search completion; more minor tweaks.
Diffstat (limited to 'background_scripts/completion_engines.coffee')
| -rw-r--r-- | background_scripts/completion_engines.coffee | 17 | 
1 files changed, 10 insertions, 7 deletions
| diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index 51799971..ac5c86aa 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -126,7 +126,8 @@ CompletionEngines =    # The amount of time to wait for new requests before launching the HTTP request.  The intention is to cut    # down on the number of HTTP requests we issue. -  delay: 100 +  # delay: 100 +  delay: 0    get: (searchUrl, url, callback) ->      xhr = new XMLHttpRequest() @@ -190,20 +191,22 @@ CompletionEngines =        else          # We add a short delay, even for a cache hit.  This avoids an ugly flicker when the additional          # suggestions are posted. -        Utils.setTimeout 75, => +        Utils.setTimeout 50, =>            console.log "hit", completionCacheKey if @debug            callback @completionCache.get completionCacheKey          return      if @mostRecentQuery? and @mostRecentSuggestions? -      # If the user appears to be typing a continuation of the characters of the most recent query, and those -      # characters are also common to all of the most recent suggestions, then we can re-use the previous -      # suggestions. +      # If the user appears to be typing a continuation of the characters of the most recent query, then we +      # can re-use the previous suggestions.        reusePreviousSuggestions = do (query) =>          query = queryTerms.join(" ").toLowerCase() +        # Verify that the previous query is a prefix of the current query.          return false unless 0 == query.indexOf @mostRecentQuery.toLowerCase() -        previousSuggestions = @mostRecentSuggestions.map (s) -> s.toLowerCase() -        return false unless query.length <= Utils.longestCommonPrefix previousSuggestions +        # Ensure that every previous suggestion contains the text of the new query. +        for suggestion in (@mostRecentSuggestions.map (s) -> s.toLowerCase()) +          return false unless 0 <= suggestion.indexOf query +        # Ok. Re-use the suggestion.          true        if reusePreviousSuggestions | 
