From 7bf8cb11db08c61417a4d72b95c2905a4869cf67 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 29 Feb 2016 11:53:05 +0000 Subject: Key bindings; small tweaks... - simplify pass key condition - don't keep key-parsing Regexp in memory - we should reset the key state when the pass keys change --- content_scripts/mode_key_handler.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/mode_key_handler.coffee b/content_scripts/mode_key_handler.coffee index ecfcacd6..78ce3680 100644 --- a/content_scripts/mode_key_handler.coffee +++ b/content_scripts/mode_key_handler.coffee @@ -2,7 +2,7 @@ class KeyHandlerMode extends Mode keydownEvents: {} setKeyMapping: (@keyMapping) -> @reset() - setPassKeys: (@passKeys) -> + setPassKeys: (@passKeys) -> @reset() constructor: (options) -> @commandHandler = options.commandHandler ? (->) @@ -91,8 +91,7 @@ class KeyHandlerMode extends Mode # Keystrokes are *never* considered passKeys if the user has begun entering a command. So, for example, if # 't' is a passKey, then 'gt' and '99t' are neverthless handled as regular keys. unlessKeyCharIsPassKey: (keyChar, nonPassKeyCallback) -> - if @passKeys and @countPrefix == 0 and @keyState.length == 1 and - keyChar?.length == 1 and 0 <= @passKeys.indexOf keyChar + if @countPrefix == 0 and @keyState.length == 1 and keyChar in (@passKeys ? "") @stopBubblingAndTrue else nonPassKeyCallback() -- cgit v1.2.3