aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--background_scripts/commands.coffee11
-rw-r--r--content_scripts/mode_key_handler.coffee5
2 files changed, 7 insertions, 9 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index a36b0c7e..25acdc03 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -101,17 +101,16 @@ Commands =
@keyToCommandRegistry = {}
@mapKeyToCommand { key, command } for own key, command of defaultKeyMappings
- # Keys are either literal characters, or "named" - for example <a-b> (alt+b), <left> (left arrow) or <f12>
- # This regular expression captures two groups: the first is a named key, the second is the remainder of the
- # string.
- namedKeyRegex: /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,5})>)(.*)$/
-
generateKeyStateMapping: ->
+ # Keys are either literal characters, or "named" - for example <a-b> (alt+b), <left> (left arrow) or <f12>
+ # This regular expression captures two groups: the first is a named key, the second is the remainder of
+ # the string.
+ namedKeyRegex = /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,5})>)(.*)$/
keyStateMapping = {}
for own keys, registryEntry of @keyToCommandRegistry
currentMapping = keyStateMapping
while 0 < keys.length
- [key, keys] = if 0 == keys.search @namedKeyRegex then [RegExp.$1, RegExp.$2] else [keys[0], keys[1..]]
+ [key, keys] = if 0 == keys.search namedKeyRegex then [RegExp.$1, RegExp.$2] else [keys[0], keys[1..]]
if currentMapping[key]?.command
break # Do not overwrite existing command bindings, they take priority.
else if 0 < keys.length
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()