From fb876164338e865144402689b159e4edf35cf777 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 1 Oct 2016 06:21:14 +0100 Subject: Fix find-mode hangs. "/" followed immediately by "i" can hang Vimium. The problem is that launching find mode is asynchronous (we wait until the HUD is available). Because normal mode is still active, we can enter insert mode *before* the find-mode HUD receives the focus. The result is that we end up in both find mode and insert mode, the HUD has the focus, but the HUD is in insert mode, so it ignores keyboard events (including `Escape`). The only way out is to click the page's body and then type `Escape`. This commit demonstrates the problem: 7d2b00411eae3293fa4c7b1f61b384c0c495b5a2. This happens in practice, for example while a busy page is loading. This commit fixes this by ensuring that find-mode blocks keyboard events immediately (and synchronously) on launch. --- content_scripts/mode_find.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 4c146889..8621edf8 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -71,6 +71,10 @@ class FindMode extends Mode name: "find" indicator: false exitOnClick: true + exitOnEscape: true + # This prevents further Vimium commands launching before the find-mode HUD receives the focus. + # E.g. "/" followed quickly by "i" should not leave us in insert mode. + suppressAllKeyboardEvents: true HUD.showFindMode this -- cgit v1.2.3