diff options
| author | Stephen Blott | 2016-02-27 15:03:09 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-03-05 05:37:40 +0000 |
| commit | 47de80f2fcb03c8741ab46308ce982209f74f6ac (patch) | |
| tree | c9070f1e1777ddef4f10bf91280d88114704408a /content_scripts/mode_passkeys.coffee | |
| parent | 3f63ceb19046157692eac9e9a13486af7e50a57e (diff) | |
| download | vimium-47de80f2fcb03c8741ab46308ce982209f74f6ac.tar.bz2 | |
Key bindings; fix passkeys.
Diffstat (limited to 'content_scripts/mode_passkeys.coffee')
| -rw-r--r-- | content_scripts/mode_passkeys.coffee | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/content_scripts/mode_passkeys.coffee b/content_scripts/mode_passkeys.coffee index 631eb621..426e5369 100644 --- a/content_scripts/mode_passkeys.coffee +++ b/content_scripts/mode_passkeys.coffee @@ -1,6 +1,6 @@ class PassKeysMode extends Mode - constructor: -> + constructor: (@normalMode) -> super name: "passkeys" trackState: true # Maintain @enabled, @passKeys and @keyQueue. @@ -8,14 +8,16 @@ class PassKeysMode extends Mode keypress: (event) => @handleKeyChar event, String.fromCharCode event.charCode keyup: (event) => @handleKeyChar event, KeyboardUtils.getKeyChar event - # Keystrokes are *never* considered passKeys if the keyQueue is not empty. So, for example, if 't' is a - # passKey, then 'gt' and '99t' will neverthless be handled by Vimium. + # Keystrokes are *never* considered passKeys if the user has begin entering a command. So, for example, if + # 't' is a passKey, then 'gt' and '99t' will neverthless be handled by Vimium. handleKeyChar: (event, keyChar) -> return @continueBubbling if event.altKey or event.ctrlKey or event.metaKey - if keyChar and not @keyQueue and keyChar.length == 1 and 0 <= @passKeys.indexOf keyChar - @stopBubblingAndTrue - else - @continueBubbling + return @continueBubbling unless keyChar and keyChar.length == 1 + # Test whether the user has already begun entering a command. + return @continueBubbling unless @normalMode.isFirstKeyChar keyChar + return @continueBubbling unless 0 <= @passKeys.indexOf keyChar + # This is a passkey. + @stopBubblingAndTrue root = exports ? window root.PassKeysMode = PassKeysMode |
