aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-04-03 06:21:44 +0100
committerStephen Blott2016-04-03 06:33:18 +0100
commit9d3e6cc399e69aec49ff59e78e58d403fe0bdf4b (patch)
tree7d022f9fcf6dc3c1d8b12b2eb0c552021daa3b92
parent96c74e4aa7e39a99bf5511440ba7a4155f1e2db8 (diff)
downloadvimium-9d3e6cc399e69aec49ff59e78e58d403fe0bdf4b.tar.bz2
Remove blocking mode when no hints found.
This fixes an error in 39adee9090fc5aadfd5dd681f91b80025084858a. Specifically, if there are no hints to select from, or no documentElement, then link-hints mode exits without initiating an actual mode (i.e. without calling its super() constructor). With 39adee9090fc5aadfd5dd681f91b80025084858a, that leaves a mode in place which blocks all keyboard events, thereby rendering Vimium entirely hung. See this line: https://github.com/philc/vimium/commit/39adee9090fc5aadfd5dd681f91b80025084858a#diff-e9abcb9ebcdb5af8e9f33651364673a1R59. Here: - we explicitly remove the keyboard-blocking mode - we add exitOnEscape (so that the situation is at least recoverable), and - we add an indicator (so that we can see what's going on). It is proposed that the indicator is a temporary feature, while the global link hints feature is in shake down.
-rw-r--r--content_scripts/link_hints.coffee10
1 files changed, 9 insertions, 1 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 53b5e062..910e65f1 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -51,6 +51,8 @@ availableModes = [OPEN_IN_CURRENT_TAB, OPEN_IN_NEW_BG_TAB, OPEN_IN_NEW_FG_TAB, O
HintCoordinator =
onExit: []
+ localHints: null
+ suppressKeyboardEvents: null
sendMessage: (messageType, request = {}) ->
Frame.postMessage "linkHintsMessage", extend request, {messageType}
@@ -59,7 +61,11 @@ HintCoordinator =
# We need to communicate with the background page (and other frames) to initiate link-hints mode. To
# prevent other Vimium commands from being triggered before link-hints mode is launched, we install a
# temporary mode to block keyboard events.
- new SuppressAllKeyboardEvents singleton: "link-hints-mode"
+ @suppressKeyboardEvents = new SuppressAllKeyboardEvents
+ name: "link-hints/suppress-keyboard-events"
+ singleton: "link-hints-mode"
+ indicator: "Launching hints..."
+ exitOnEscape: true
@onExit = [onExit]
@sendMessage "prepareToActivateMode", modeIndex: availableModes.indexOf mode
@@ -75,6 +81,8 @@ HintCoordinator =
# We also propagate the key state between frames. Therefore, the hint-selection process proceeds in lock
# step in every frame, and @linkHintsMode is in the same state in every frame.
activateMode: ({hintDescriptors, modeIndex, originatingFrameId}) ->
+ @suppressKeyboardEvents?.exit() if @suppressKeyboardEvents?.modeIsActive
+ @suppressKeyboardEvents = null
# Ensure that the settings are loaded. The request might have been initiated in another frame.
Settings.onLoaded =>
@onExit = [] unless frameId == originatingFrameId