From e56b5fc0129dd67d7978ee6453d366cb3642a4e2 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 10 May 2015 09:49:09 +0100 Subject: Search completion; use cached suggestions synchronously. Conflicts: background_scripts/completion_engines.coffee --- background_scripts/completion_engines.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index 729c68b0..78782513 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -214,8 +214,9 @@ 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. + # 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. reusePreviousSuggestions = do (query) => query = queryTerms.join(" ").toLowerCase() return false unless 0 == query.indexOf @mostRecentQuery.toLowerCase() @@ -228,6 +229,8 @@ CompletionEngines = @mostRecentQuery = queryTerms.join " " return callback @completionCache.set completionCacheKey, @mostRecentSuggestions + return null if returnResultsOnlyFromCache + fetchSuggestions = (engine, callback) => url = engine.getUrl queryTerms query = queryTerms.join(" ").toLowerCase() -- cgit v1.2.3