Remove ability to associate a binding set with a function

This was cool, but it's really hard to optimize the keymap with this feature because we never know if a keystroke will match against a binding set with a function, which will force us to always consider this binding set against every key event.
This commit is contained in:
Nathan Sobo
2012-11-02 13:39:21 -06:00
parent 0c3498d29f
commit 2c211ba504
2 changed files with 19 additions and 74 deletions

View File

@@ -12,19 +12,15 @@ class BindingSet
commandForEvent: null
parser: null
constructor: (@selector, mapOrFunction, @index) ->
constructor: (@selector, commandsByKeystrokes, @index) ->
@parser = PEG.buildParser(fs.read(require.resolve 'keystroke-pattern.pegjs'))
@specificity = Specificity(@selector)
@commandsByKeystrokes = {}
@commandsByKeystrokes = @normalizeCommandsByKeystrokes(commandsByKeystrokes)
if _.isFunction(mapOrFunction)
@commandForEvent = mapOrFunction
else
@commandsByKeystrokes = @normalizeCommandsByKeystrokes(mapOrFunction)
@commandForEvent = (event) =>
for keystrokes, command of @commandsByKeystrokes
return command if event.keystrokes == keystrokes
null
commandForEvent: (event) ->
for keystrokes, command of @commandsByKeystrokes
return command if event.keystrokes == keystrokes
null
matchesKeystrokePrefix: (event) ->
eventKeystrokes = event.keystrokes.split(' ')