aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-02-29 06:31:43 +0000
committerStephen Blott2016-03-05 05:40:11 +0000
commite4193e2752ee7132ff16a7ba977857f70df2946b (patch)
treec6ac4221e85cb2ffcb6daa58bd0932da755a0b34
parent9cfa00bc7db3e07c3abbeb09e483d9fdf20bbc17 (diff)
downloadvimium-e4193e2752ee7132ff16a7ba977857f70df2946b.tar.bz2
Key bindings; tweaks.
-rw-r--r--background_scripts/main.coffee2
-rw-r--r--content_scripts/mode_key_handler.coffee10
-rw-r--r--content_scripts/vimium_frontend.coffee2
-rw-r--r--tests/dom_tests/dom_tests.coffee4
4 files changed, 9 insertions, 9 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index d1ca501d..614b74c0 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -370,7 +370,7 @@ chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) ->
# End action functions
runBackgroundCommand = ({frameId, registryEntry, count}, sender) ->
- if registryEntry.command.split(".")[0] == "Vomnibar"
+ if registryEntry.command.startsWith "Vomnibar."
chrome.tabs.sendMessage sender.tab.id,
name: "openVomnibar", sourceFrameId: frameId, registryEntry: registryEntry
else if registryEntry.passCountToFunction
diff --git a/content_scripts/mode_key_handler.coffee b/content_scripts/mode_key_handler.coffee
index 60633895..8c4ded43 100644
--- a/content_scripts/mode_key_handler.coffee
+++ b/content_scripts/mode_key_handler.coffee
@@ -63,12 +63,12 @@ class KeyHandlerMode extends Mode
handleKeyChar: (event, keyChar) ->
bgLog "Handling key #{keyChar}, mode=#{@name}."
@advanceKeyState keyChar
- commands = @keyState.filter (entry) -> entry.command
- if 0 < commands.length
- countPrefix = if 0 < @countPrefix then @countPrefix else 1
+ command = (@keyState.filter (entry) -> entry.command)[0]
+ if command?
+ count = if 0 < @countPrefix then @countPrefix else 1
@reset()
- bgLog "Calling mode=#{@name}, command=#{commands[0].command}, count=#{countPrefix}."
- @commandHandler command: commands[0], count: countPrefix, event: event
+ bgLog "Calling mode=#{@name}, command=#{command.command}, count=#{count}."
+ @commandHandler {command, count}
false # Suppress event.
# This returns the first key-state entry for which keyChar is mapped. The return value is truthy if a match
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 46b21ed0..a4dd6986 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -108,7 +108,7 @@ class NormalMode extends KeyHandlerMode
if area == "local" and changes.normalModeKeyStateMapping?.newValue
@setKeyMapping changes.normalModeKeyStateMapping.newValue
- commandHandler: ({command: registryEntry, count, event}) ->
+ commandHandler: ({command: registryEntry, count}) ->
count *= registryEntry.options.count ? 1
count = 1 if registryEntry.noRepeat
diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee
index 6309525f..ee61aba9 100644
--- a/tests/dom_tests/dom_tests.coffee
+++ b/tests/dom_tests/dom_tests.coffee
@@ -377,7 +377,7 @@ context "Normal mode",
should "suppress passKeys with a non-empty key state (a key)", ->
sendKeyboardEvent "z"
sendKeyboardEvent "p"
- assert.equal 0, pageKeyboardEventCount
+ assert.equal pageKeyboardEventCount, 0
context "Insert mode",
setup ->
@@ -396,7 +396,7 @@ context "Insert mode",
should "resume normal mode after leaving insert mode", ->
@insertMode.exit()
sendKeyboardEvent "m"
- assert.equal 0, pageKeyboardEventCount
+ assert.equal pageKeyboardEventCount, 0
context "Triggering insert mode",
setup ->