diff options
| author | Stephen Blott | 2012-11-11 13:22:18 +0000 |
|---|---|---|
| committer | Stephen Blott | 2012-11-11 13:22:18 +0000 |
| commit | 3dc8a03d7271c659139c157bb658795dd21298f9 (patch) | |
| tree | ecf32aec56faef3d50314e0e879ebea2d8f21248 /background_scripts/completion.coffee | |
| parent | a3eb1cbee93c4c10505f629b8bc8bc00e37adb8a (diff) | |
| download | vimium-3dc8a03d7271c659139c157bb658795dd21298f9.tar.bz2 | |
Remove history entries.
When a chrome history entry is removed, remove that entry from our
history too. Same when the entire history is removed.
Diffstat (limited to 'background_scripts/completion.coffee')
| -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. |
