From 88224d8ee99eac49a57f7137b5f056e151c6a426 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 6 Mar 2016 11:09:13 +0000 Subject: Revert "Count prefix applies only to leading mapping." This reverts commit 7774beb6643c0d905f9caba4345453790af948ad. Reverting this. It can be done better (and capture some other incorrect cases). --- content_scripts/mode_key_handler.coffee | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/mode_key_handler.coffee b/content_scripts/mode_key_handler.coffee index f2c4a745..586f9193 100644 --- a/content_scripts/mode_key_handler.coffee +++ b/content_scripts/mode_key_handler.coffee @@ -89,18 +89,14 @@ class KeyHandlerMode extends Mode handleKeyChar: (keyChar) -> bgLog "Handling key #{keyChar}, mode=#{@name}." - nextKeyState = (mapping[keyChar] for mapping in @keyState when keyChar of mapping) - command = (mapping for mapping in nextKeyState when "command" of mapping)[0] + # 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] 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