From 311b35e416053a0d5d03eaf7eb894375f6e0f20d Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 9 May 2015 16:47:28 +0100 Subject: Search completion; tweaks and tests. --- background_scripts/completion.coffee | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 850a257d..7966452d 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -375,33 +375,37 @@ class SearchEngineCompleter custom = searchUrl? and keyword? searchUrl ?= Settings.get "searchUrl" haveDescription = description? and 0 < description.length - description ||= "#{if custom then "custom " else ""}search" + description ||= "search#{if custom then " [#{keyword}]" else ""}" queryTerms = queryTerms[1..] if custom query = queryTerms.join " " + haveCompletionEngine = CompletionEngines.haveCompletionEngine searchUrl + # If this is a custom search engine and we have a completer, then exclude results from other completers. + filter = + if custom and haveCompletionEngine + (suggestion) -> suggestion.type == description + else + null + # For custom search engines, we add an auto-selected suggestion. if custom suggestions.push new Suggestion queryTerms: queryTerms type: description url: Utils.createSearchUrl queryTerms, searchUrl - title: if haveDescription then query else "#{keyword}: #{query}" + title: query relevancy: 1 highlightTerms: false - autoSelect: true + insertText: query + # NOTE (smblott) Disbaled pending consideration of how to handle text selection within the vomnibar + # itself. + # autoSelect: true # Always reset the selection to this suggestion on query change. The UX is weird otherwise. - forceAutoSelect: true + # forceAutoSelect: true # Suppress the "w" from "w query terms" in the vomnibar input. suppressLeadingKeyword: true - - haveCompletionEngine = CompletionEngines.haveCompletionEngine searchUrl - # If this is a custom search engine and we have a completer, then exclude results from other completers. - filter = - if custom and haveCompletionEngine - (suggestion) -> suggestion.type == description - else - null + completeSuggestions: filter? # Post suggestions and bail if there is no prospect of adding further suggestions. if queryTerms.length == 0 or not haveCompletionEngine -- cgit v1.2.3