From 9d3e6cc399e69aec49ff59e78e58d403fe0bdf4b Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 3 Apr 2016 06:21:44 +0100 Subject: 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. --- content_scripts/link_hints.coffee | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'content_scripts') 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 -- cgit v1.2.3