diff options
author | Florrie <towerofnix@gmail.com> | 2017-11-08 12:18:57 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2017-11-08 12:19:05 -0400 |
commit | 6d454e06570b727221eff348408db51033957367 (patch) | |
tree | 5a0856cea0a254a2819f1aeceac1e5c5869c0c46 /src | |
parent | 5ccf456d9ba332d587c97e8724a5b767e96a5802 (diff) |
Only run 'top' keybinding for a specific combo
This lets custom keybinding files partially overwrite pre- existing ketbindings.
Diffstat (limited to 'src')
-rw-r--r-- | src/keybinder.js | 7 | ||||
-rwxr-xr-x | src/play.js | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/keybinder.js b/src/keybinder.js index d6e0113..784484c 100644 --- a/src/keybinder.js +++ b/src/keybinder.js @@ -49,13 +49,16 @@ module.exports.compileKeybindings = function(bindings, commands) { return function(inputData) { if (buffer.equals(inputData)) { commands[command](...args) + return true } } }).filter(Boolean) return function(inputData) { - for (let handler of handlers) { - handler(inputData) + for (const handler of handlers) { + if (handler(inputData)) { + break + } } } } diff --git a/src/play.js b/src/play.js index ac6a232..54d1f4e 100755 --- a/src/play.js +++ b/src/play.js @@ -173,7 +173,9 @@ async function main(args) { keybindings.splice(0) } - keybindings.push(...openedKeybindings) + // Place new keybindings at the top of the array, so that they are + // prioritized over old ones. + keybindings.unshift(...openedKeybindings) } function requiresOpenPlaylist() { |