aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-02-28 12:14:14 +0000
committerStephen Blott2016-02-28 12:14:14 +0000
commiteb2eb7c4368108fcd0e1472f6ef34ca2416b5371 (patch)
treeb8f134d95e81281ac32f887c8d985c4f4977e4cd
parenta1cf7228f47c2f4c837a442deb7b07d94b5dd2b1 (diff)
downloadvimium-eb2eb7c4368108fcd0e1472f6ef34ca2416b5371.tar.bz2
Fix for <count>F.
We were immediately restarting link-hints mode if a count was present. Unfortunately, that meant that we were detecting our own link-hint click and exiting immediately. So, with a count of 6, we were only getting 3 link-hint activations. To avoid this, we add a short delay (just nextTick). Also, move some other stuff arund to make sure this works in all cases (e.g. wait-for-enter).
-rw-r--r--content_scripts/link_hints.coffee19
1 files changed, 9 insertions, 10 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 8d75ed32..c8f9b6f9 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -26,7 +26,9 @@ LinkHints =
# can exit following which we do not restart hints mode.
return if event?.type == "keydown" and KeyboardUtils.isEscape event
return if event?.type == "keydown" and event.keyCode in [ keyCodes.backspace, keyCodes.deleteKey ]
- LinkHints.activateMode count-1, mode
+ # Wait for the next tick to allow the previous mode to exit. It might yet generate a click event,
+ # which would cause our new mode to exit immediately.
+ Utils.nextTick -> LinkHints.activateMode count-1, mode
activateModeToOpenInNewTab: (count) -> @activateMode count, OPEN_IN_NEW_BG_TAB
activateModeToOpenInNewForegroundTab: (count) -> @activateMode count, OPEN_IN_NEW_FG_TAB
@@ -389,11 +391,10 @@ class LinkHintsMode
@linkActivator(clickEl)
LinkHints.activateModeWithQueue() if @mode is OPEN_WITH_QUEUE
- delay = 0 if waitForEnter
- @deactivateMode delay, =>
- if waitForEnter
- new WaitForEnter @matchedLink.rect, linkActivator
- else
+ if waitForEnter
+ new WaitForEnter @matchedLink.rect, => @deactivateMode 0, linkActivator
+ else
+ @deactivateMode delay, =>
DomUtils.flashRect @matchedLink.rect
linkActivator()
@@ -421,18 +422,16 @@ class LinkHintsMode
@onExit?()
@onExit = null
@tabCount = 0
+ callback?()
if delay
# Install a mode to block keyboard events if the user is still typing. The intention is to prevent the
# user from inadvertently launching Vimium commands when typing the link text.
- new TypingProtector delay, @matchedLink?.rect, ->
- deactivate()
- callback?()
+ new TypingProtector delay, @matchedLink?.rect, deactivate
else
# We invoke deactivate() directly (instead of setting a timeout of 0) so that deactivateMode() can be
# tested synchronously.
deactivate()
- callback?()
# Use characters for hints, and do not filter links by their text.
class AlphabetHints