Add mappingsForKeystrokeMatchingElement

This commit is contained in:
probablycorey
2013-11-14 16:05:10 -08:00
parent fd443a8b68
commit fc0a46d6b2

View File

@@ -82,8 +82,7 @@ class Keymap
element = event.target
element = rootView[0] if element == document.body
keystroke = @keystrokeStringForEvent(event, @queuedKeystroke)
mappings = @mappingsForKeystroke(keystroke)
mappings = @mappingsMatchingElement(mappings, element)
mappings = @mappingsForKeystrokeMatchingElement(keystroke, element)
if mappings.length == 0 and @queuedKeystroke
@queuedKeystroke = null
@@ -118,6 +117,10 @@ class Keymap
mappings
mappingsForKeystrokeMatchingElement: (keystroke, element) ->
mappings = @mappingsForKeystroke(keystroke)
@mappingsMatchingElement(element, mappings)
mappingsForKeystroke: (keystroke) ->
mappings = @allMappings().filter (mapping) ->
multiKeystroke = /\s/.test keystroke