From fdcdd0113049042c94b2b56a6b716e2da58b860e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 10 Jan 2015 08:25:02 +0000 Subject: Modes; instrument for debugging... - Set Mode.debug to true to see mode activation/deactivation on the console. - Use Mode.log() to see a list of currently-active modes. - Use handlerStack.debugOn() to enable debugging of the handler stack. --- content_scripts/vimium_frontend.coffee | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index a9bf30a3..1406b1e7 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -396,10 +396,16 @@ extend window, visibleInputs[selectedInputIndex].element.focus() @suppressEvent else unless event.keyCode == KeyboardUtils.keyCodes.shiftKey - @exit event - # In @exit(), we just pushed a new mode (usually insert mode). Restart bubbling, so that the - # new mode can now see the event too. - @restartBubbling + mode = @exit event + if mode + # In @exit(), we just pushed a new mode (usually insert mode). Restart bubbling, so that the + # new mode can now see the event too. + # Exception: If the new mode exits on Escape, and this key event is Escape, then rebubbling the + # event will just cause the mode to exit immediately. So we suppress Escapes. + if mode.options.exitOnEscape and KeyboardUtils.isEscape event + @suppressEvent + else + @restartBubbling visibleInputs[selectedInputIndex].element.focus() return @exit() if visibleInputs.length == 1 -- cgit v1.2.3