diff options
| author | Jez Ng | 2012-10-24 22:06:35 -0400 |
|---|---|---|
| committer | Jez Ng | 2012-10-29 17:52:29 -0400 |
| commit | 7b893f5e46678a1713aaa36ff179ff5a24610d2a (patch) | |
| tree | e457dc55c26664fc194358a591ef46f7f9265ff7 /background_scripts | |
| parent | 0964cf83b338915f9c0e3e0b581e4995ba4fb742 (diff) | |
| download | vimium-7b893f5e46678a1713aaa36ff179ff5a24610d2a.tar.bz2 | |
List all tabs in Vomnibar even before user starts typing.
Closes #671.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/completion.coffee | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 58725fa0..f7313756 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -91,8 +91,12 @@ class BookmarkCompleter onBookmarksLoaded: -> @performSearch() if @currentSearch performSearch: -> - results = @bookmarks.filter (bookmark) => - RankingUtils.matches(@currentSearch.queryTerms, bookmark.url, bookmark.title) + results = + if @currentSearch.queryTerms.length > 0 + @bookmarks.filter (bookmark) => + RankingUtils.matches(@currentSearch.queryTerms, bookmark.url, bookmark.title) + else + [] suggestions = results.map (bookmark) => new Suggestion(@currentSearch.queryTerms, "bookmark", bookmark.url, bookmark.title, @computeRelevancy) onComplete = @currentSearch.onComplete @@ -123,7 +127,11 @@ class HistoryCompleter @currentSearch = { queryTerms: @queryTerms, onComplete: @onComplete } results = [] HistoryCache.use (history) => - results = history.filter (entry) -> RankingUtils.matches(queryTerms, entry.url, entry.title) + results = + if queryTerms.length > 0 + history.filter (entry) -> RankingUtils.matches(queryTerms, entry.url, entry.title) + else + [] suggestions = results.map (entry) => new Suggestion(queryTerms, "history", entry.url, entry.title, @computeRelevancy, entry) onComplete(suggestions) @@ -244,7 +252,6 @@ RankingUtils = # Whether the given URL or title match any one of the query terms. This is used to prune out irrelevant # suggestions before we try to rank them. matches: (queryTerms, url, title) -> - return false if queryTerms.length == 0 for term in queryTerms regexp = RegexpCache.get(term) return false unless title.match(regexp) || url.match(regexp) |
