diff options
| author | Stephen Blott | 2015-05-15 07:27:26 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-15 07:27:26 +0100 |
| commit | cc6c64fa5729a07be4567b2ca11bfadec6b02be2 (patch) | |
| tree | 2c23651263274b43099745a232b4c11be676b8a6 | |
| parent | df187b3f5a00ecc3a4cd0846167e0f1fc5473f90 (diff) | |
| download | vimium-cc6c64fa5729a07be4567b2ca11bfadec6b02be2.tar.bz2 | |
Give the vomnibar a (kind of) history.
| -rw-r--r-- | background_scripts/completion.coffee | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 5755bfaf..2ee4a666 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -226,12 +226,23 @@ class HistoryCompleter @currentSearch = { queryTerms: @queryTerms, onComplete: @onComplete } results = [] HistoryCache.use (history) => + searchUrl = Settings.get "searchUrl" + searchUrlTerminator = new RegExp "[&#/]" results = if queryTerms.length > 0 history.filter (entry) -> RankingUtils.matches(queryTerms, entry.url, entry.title) else [] onComplete results.map (entry) => + # If this history URL starts with the search URL, we reconstruct the original search terms, and insert + # them into the vomnibar when this suggestion is selected. + insertText = + if entry.url.startsWith searchUrl + try + entry.url[searchUrl.length..].split(searchUrlTerminator)[0].split("+").map(decodeURIComponent).join " " + catch + null + new Suggestion queryTerms: queryTerms type: "history" @@ -239,6 +250,7 @@ class HistoryCompleter title: entry.title relevancyFunction: @computeRelevancy relevancyData: entry + insertText: insertText computeRelevancy: (suggestion) -> historyEntry = suggestion.relevancyData |
