From 7774beb6643c0d905f9caba4345453790af948ad Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 6 Mar 2016 09:13:24 +0000 Subject: Count prefix applies only to leading mapping. E.g. `7gj` should be `1j`; currently it's `7j`. --- content_scripts/mode_key_handler.coffee | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'content_scripts') 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 -- cgit v1.2.3