aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorJez Ng2012-07-07 03:43:36 -0700
committerJez Ng2012-07-07 03:43:36 -0700
commit61cd2ad7eaa720bf7aec0417336be692045442c7 (patch)
tree22b2f4c76dd3f8f617d44b308835a46ea596f292 /content_scripts
parente1c6290722343ed2fab1b63f3c925b6102c080e6 (diff)
downloadvimium-61cd2ad7eaa720bf7aec0417336be692045442c7.tar.bz2
Put hints mode under a lock.
This avoids problems when the user does something like `2f`.
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/link_hints.coffee9
1 files changed, 8 insertions, 1 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 533a8775..d2db5b12 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -20,6 +20,8 @@ LinkHints =
# Handle the link hinting marker generation and matching. Must be initialized after settings have been
# loaded, so that we can retrieve the option setting.
markerMatcher: undefined
+ # lock to ensure only one instance runs at a time
+ isActive: false
#
# To be called after linkHints has been generated from linkHintsBase.
@@ -45,6 +47,10 @@ LinkHints =
activateModeWithQueue: -> @activateMode(true, true, false)
activateMode: (openInNewTab, withQueue, copyLinkUrl) ->
+ if @isActive
+ return
+ @isActive = true
+
if (!document.getElementById("vimiumLinkHintCss"))
# linkHintCss is declared by vimiumFrontend.js and contains the user supplied css overrides.
addCssToPage(linkHintCss, "vimiumLinkHintCss")
@@ -220,7 +226,7 @@ LinkHints =
# executes after 'delay' and invokes 'callback' when it is finished.
#
deactivateMode: (delay, callback) ->
- deactivate = ->
+ deactivate = =>
if (LinkHints.markerMatcher.deactivate)
LinkHints.markerMatcher.deactivate()
if (LinkHints.hintMarkerContainingDiv)
@@ -229,6 +235,7 @@ LinkHints =
LinkHints.hintMarkers = []
handlerStack.pop()
HUD.hide()
+ @isActive = false
# we invoke the deactivate() function directly instead of using setTimeout(callback, 0) so that
# deactivateMode can be tested synchronously