aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/completion.coffee
diff options
context:
space:
mode:
authorStephen Blott2012-11-11 13:22:18 +0000
committerStephen Blott2012-11-11 13:22:18 +0000
commit3dc8a03d7271c659139c157bb658795dd21298f9 (patch)
treeecf32aec56faef3d50314e0e879ebea2d8f21248 /background_scripts/completion.coffee
parenta3eb1cbee93c4c10505f629b8bc8bc00e37adb8a (diff)
downloadvimium-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.coffee13
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.