diff options
| -rw-r--r-- | background_scripts/completion.coffee | 2 | ||||
| -rw-r--r-- | background_scripts/completion_engines.coffee | 2 | ||||
| -rw-r--r-- | pages/vomnibar.coffee | 18 |
3 files changed, 12 insertions, 10 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 4fa91b9d..ccb5e4e6 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -474,7 +474,7 @@ class SearchEngineCompleter # adding further suggestions. if queryTerms.length == 0 or cachedSuggestions? or not haveCompletionEngine if cachedSuggestions? - console.log "using cached suggestions" + console.log "using cached suggestions:", query suggestions.push cachedSuggestions.map(mkSuggestion)... return onComplete suggestions, { filter } diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index ac5c86aa..638d7f60 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -210,7 +210,7 @@ CompletionEngines = true if reusePreviousSuggestions - console.log "reuse previous query", @mostRecentQuery if @debug + console.log "reuse previous query:", @mostRecentQuery if @debug @mostRecentQuery = queryTerms.join " " return callback @completionCache.set completionCacheKey, @mostRecentSuggestions diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index 85930aff..df67d2eb 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -129,10 +129,10 @@ class VomnibarUI currentLength = @input.value.length @previousLength = currentLength - # We only highlight matches if the query gets longer (so, not on deletions). + # We only highlight matches when the query gets longer (so, not on deletions). return unless previousLength < currentLength - # Get the completions for which we can highlight matching text. + # Get the completions from which we can select text to highlight. completions = @completions.filter (completion) -> completion.highlightCommonMatches? and completion.highlightCommonMatches @@ -173,19 +173,21 @@ class VomnibarUI length # Bail if there's nothing to complete. - return unless query.length < length - - # Don't highlight only whitespace (that is, the entire common text consists only of whitespace). - return if /^\s+$/.test suggestions[0].slice query.length, length + return unless query.length < length completion = suggestions[0].slice query.length, length + # Don't complete trailing whitespace; so, strip it. Then , verify that the completion is still long + # enough. + completion = completion.replace /\s+$/, "" + return unless 0 < completion.length + # If the typed text is all lower case, then make the completion lower case too. completion = completion.toLowerCase() unless /[A-Z]/.test @input.value - # Highlight match. + # Insert the completion and highlight it. @input.value = @input.value + completion - @input.setSelectionRange query.length, length + @input.setSelectionRange query.length, query.length + completion.length # # Returns the user's action ("up", "down", "tab", "enter", "dismiss", "delete" or null) based on their |
