mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
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:
@@ -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(' ')
|
||||
|
||||
Reference in New Issue
Block a user