diff options
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/completion.coffee | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 25f76c1e..8ab71290 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -365,6 +365,7 @@ HistoryCache = history.sort @compareHistoryByUrl @history = history chrome.history.onVisited.addListener(@onPageVisited.bind(this)) + chrome.history.onVisitRemoved.addListener(@onVisitRemoved.bind(this)) callback(@history) for callback in @callbacks @callbacks = null @@ -383,6 +384,18 @@ HistoryCache = else @history.splice(i, 0, newPage) + # When a page is removed from the chrome history, remove it from the vimium history too. + onVisitRemoved: (toRemove) -> + if toRemove.allHistory + @history = [] + else + toRemove.urls.map (url) => + i = HistoryCache.binarySearch({url:url}, @history, @compareHistoryByUrl) + # TODO (smblott) + # The `i < @history.length` condition below should not be necessary. It can be removed when `binarySearch` is fixed. + if i < @history.length and @history[i].url == url + @history.splice(i, 1) + # Returns the matching index or the closest matching index if the element is not found. That means you # must check the element at the returned index to know whether the element was actually found. # This method is used for quickly searching through our history cache. |
