From 61cd2ad7eaa720bf7aec0417336be692045442c7 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Sat, 7 Jul 2012 03:43:36 -0700 Subject: Put hints mode under a lock. This avoids problems when the user does something like `2f`. --- content_scripts/link_hints.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'content_scripts/link_hints.coffee') 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 -- cgit v1.2.3