diff options
| -rw-r--r-- | background_scripts/completion.coffee | 32 | ||||
| -rw-r--r-- | background_scripts/completion_engines.coffee | 6 |
2 files changed, 27 insertions, 11 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index dc5b2737..6e57f0d4 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -63,6 +63,11 @@ class Suggestion a.href = url a.protocol + "//" + a.hostname + getHostname: (url) -> + a = document.createElement 'a' + a.href = url + a.hostname + shortenUrl: (url) -> @stripTrailingSlash(url).replace(/^https?:\/\//, "") stripTrailingSlash: (url) -> @@ -396,10 +401,24 @@ class SearchEngineCompleter # We filter out the empty strings late so that we can distinguish between, for example, "w" and "w ". queryTerms = queryTerms.filter (t) -> 0 < t.length - return onComplete suggestions if queryTerms.length == 0 + # NOTE(smblott) I'm having difficulty figuring out to do the filtering, here. Exclusive should mean + # exclusive to what? + exclusive = if custom and CompletionEngines.haveCompletionEngine searchUrl then description else null + # exclusive = + # if custom and CompletionEngines.haveCompletionEngine searchUrl + # suggestions[0].getHostname suggestions[0].url + # else + # null + # exclusive = + # if custom and CompletionEngines.haveCompletionEngine searchUrl + # searchUrl.split("%s")?[0] + # else + # null + if queryTerms.length == 0 + return onComplete suggestions, { exclusive } onComplete suggestions, - exclusive: if custom and CompletionEngines.haveCompletionEngine searchUrl then description else null + exclusive: exclusive continuation: (existingSuggestions, onComplete) => suggestions = [] # For custom search-engine queries, this adds suggestions only if we have a completer. For other queries, @@ -491,9 +510,8 @@ class MultiCompleter # continuation if another query is already waiting. This is for slow tasks which should be done # asynchronously (e.g. HTTP GET). continuation: null - # If truthy, completions from other completers should be suppressed. The truthy value should be the - # type of the completer (e.g. "custom search"). All other completion types are suppressed. - exclusive: false + # If truthy, non-matching completions from other completers should be suppressed. + exclusive: null (queryTerms, onComplete) -> # Allow only one query to run at a time. @@ -518,8 +536,8 @@ class MultiCompleter console.log completer activeCompleters = activeCompleters.filter (i) -> i != index suggestions.push newSuggestions... - continuation = continuation ? options.continuation - exclusive = options.exclusive if options.exclusive? + continuation ?= options.continuation + exclusive ?= options.exclusive if activeCompleters.length == 0 # All the completers have now returned; we combine the results, post them and call any diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index ff10f4b5..badae126 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -165,10 +165,8 @@ CompletionEngines = @mostRecentHandler = null query = queryTerms.join "" - # We don't complete less then three characters: the results are usually useless. This also prevents - # one- and two-character custom search engine keywords from being sent to the default completer (e.g. - # the initial "w" before typing "w something" for Wikipedia). - return callback [] unless 3 <= query.length + # We don't complete single characters: the results are usually useless. + return callback [] unless 1 < query.length # We don't complete regular URLs or Javascript URLs. return callback [] if 1 == queryTerms.length and Utils.isUrl query |
