diff options
| author | Stephen Blott | 2016-03-06 09:13:24 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-03-06 09:13:24 +0000 |
| commit | 7774beb6643c0d905f9caba4345453790af948ad (patch) | |
| tree | 5f013286058e7947d42970f5014247adccc8aacd | |
| parent | a69a3fdb380e750c3aeaf90512f7ca49366e9569 (diff) | |
| download | vimium-7774beb6643c0d905f9caba4345453790af948ad.tar.bz2 | |
Count prefix applies only to leading mapping.
E.g. `7gj` should be `1j`; currently it's `7j`.
| -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 |
