diff options
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/mode_key_handler.coffee | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/content_scripts/mode_key_handler.coffee b/content_scripts/mode_key_handler.coffee index fdcac430..9946dddf 100644 --- a/content_scripts/mode_key_handler.coffee +++ b/content_scripts/mode_key_handler.coffee @@ -87,14 +87,18 @@ class KeyHandlerMode extends Mode handleKeyChar: (keyChar) -> bgLog "Handling key #{keyChar}, mode=#{@name}." - # Advance the key state. The new key state is the current mappings of keyChar, plus @keyMapping. - @keyState = [(mapping[keyChar] for mapping in @keyState when keyChar of mapping)..., @keyMapping] - command = (mapping for mapping in @keyState when "command" of mapping)[0] + nextKeyState = (mapping[keyChar] for mapping in @keyState when keyChar of mapping) + command = (mapping for mapping in nextKeyState when "command" of mapping)[0] if command + # Any count prefix applies only to the leading @keyState mapping; e.g., `7gj` should be `1j`. + @countPrefix = 0 unless command == @keyState[0][keyChar] count = if 0 < @countPrefix then @countPrefix else 1 bgLog "Calling mode=#{@name}, command=#{command.command}, count=#{count}." @reset() @commandHandler {command, count} + else + # Advance the key state. + @keyState = [nextKeyState..., @keyMapping] false # Suppress event. root = exports ? window |
