From 0c7668d6cc46cf24081b6b64ece27faef6667dea Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 17 May 2015 11:30:30 +0100 Subject: TabToOpen: tidy up pre-PR. --- background_scripts/completion.coffee | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index d5c6c23a..0f8f24f5 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -45,17 +45,14 @@ class Suggestion return @html if @html relevancyHtml = if @showRelevancy then "#{@computeRelevancy()}" else "" # NOTE(philc): We're using these vimium-specific class names so we don't collide with the page's CSS. - insertTextClass = if @insertText then "vomnibarInsertText" else "vomnibarNoInsertText" - insertTextIndicator = "﹢" # A small plus sign. - insertTextIndicator = "﹥" # A small "greater than" sign. @html = """
- #{insertTextIndicator}#{@type} + #{@type} #{@highlightQueryTerms Utils.escapeHtml @title}
- #{insertTextIndicator}#{@highlightQueryTerms Utils.escapeHtml @shortenUrl()} + #{@highlightQueryTerms Utils.escapeHtml @shortenUrl()} #{relevancyHtml}
""" @@ -225,7 +222,7 @@ class BookmarkCompleter RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title) class HistoryCompleter - filter: ({ queryTerms, tabToOpen }, onComplete) -> + filter: ({ queryTerms, seenTabToOpenCompletionList }, onComplete) -> @currentSearch = { queryTerms: @queryTerms, onComplete: @onComplete } results = [] HistoryCache.use (history) => @@ -233,7 +230,7 @@ class HistoryCompleter results = if queryTerms.length > 0 history.filter (entry) -> RankingUtils.matches(queryTerms, entry.url, entry.title) - else if tabToOpen + else if seenTabToOpenCompletionList # opens the completion list, even without a query. history else @@ -253,14 +250,6 @@ class HistoryCompleter # If there are no query terms, then relevancy is based on recency alone. return recencyScore if suggestion.queryTerms.length == 0 wordRelevancy = RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title) - if suggestion.insertText? - # If this suggestion matches a previous search with the default search engine, then we also score the - # previous query terms themselves (suggestion.insertText) and, if that score is higher, then we use it - # in place of the wordRelevancy score. Because the query terms are shorter than the original URL, this - # has the side effect of boosting the wordRelevancy score for previous searches with the default search - # engine. - wordRelevancy = Math.max wordRelevancy, - RankingUtils.wordRelevancy suggestion.queryTerms, suggestion.insertText, suggestion.title # Average out the word score and the recency. Recency has the ability to pull the score up, but not down. (wordRelevancy + Math.max recencyScore, wordRelevancy) / 2 @@ -406,7 +395,7 @@ class SearchEngineCompleter # This looks up the custom search engine and, if one is found, notes it and removes its keyword from the # query terms. - triageRequest: (request) -> + preprocessRequest: (request) -> @searchEngines.use (engines) => { queryTerms, query } = request request.searchEngines = engines @@ -559,7 +548,6 @@ class SearchEngineCompleter console.log suggestion.insertText, engine unless engine.description suggestion.type = engine.description ? "custom search" break - delete request.searchEngines # A completer which calls filter() on many completers, aggregates the results, ranks them, and returns the top # 10. All queries from the vomnibar come through a multi completer. @@ -578,7 +566,7 @@ class MultiCompleter # Provide each completer with an opportunity to see (and possibly alter) the request before it is # launched. - completer.triageRequest? request for completer in @completers + completer.preprocessRequest? request for completer in @completers RegexpCache.clear() { queryTerms } = request @@ -648,7 +636,7 @@ class MultiCompleter break if count++ == @maxResults seenUrls[url] = suggestion - # Give each completer an opportunity to tweak the suggestions. + # Give each completer the opportunity to tweak the suggestions. completer.postProcessSuggestions? request, suggestions for completer in @completers # Generate HTML for the remaining suggestions and return them. -- cgit v1.2.3