Now that we remove binding sets, track binding set indices explicitly

Previously we relied on the length of the binding sets, but now that
we remove them the length is not a strictly increasing number. This
could cause problem when using the index to break specificity ties.
This commit is contained in:
Nathan Sobo
2013-03-26 16:59:42 -06:00
parent 1f74b5ccb4
commit d8b4beb8bd

View File

@@ -8,6 +8,7 @@ BindingSet = require 'binding-set'
module.exports =
class Keymap
bindingSets: null
nextBindingSetIndex: 0
bindingSetsByFirstKeystroke: null
queuedKeystrokes: null
@@ -58,7 +59,7 @@ class Keymap
bindKeys: (args...) ->
name = args.shift() if args.length > 2
[selector, bindings] = args
bindingSet = new BindingSet(selector, bindings, @bindingSets.length, name)
bindingSet = new BindingSet(selector, bindings, @nextBindingSetIndex++, name)
@bindingSets.unshift(bindingSet)
for keystrokes of bindingSet.commandsByKeystrokes
keystroke = keystrokes.split(' ')[0] # only index by first keystroke