diff options
| author | Jez Ng | 2012-07-07 03:43:36 -0700 |
|---|---|---|
| committer | Jez Ng | 2012-07-07 03:43:36 -0700 |
| commit | 61cd2ad7eaa720bf7aec0417336be692045442c7 (patch) | |
| tree | 22b2f4c76dd3f8f617d44b308835a46ea596f292 /content_scripts | |
| parent | e1c6290722343ed2fab1b63f3c925b6102c080e6 (diff) | |
| download | vimium-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.coffee | 9 |
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 |
