From 8cb565ad2a6ad5112502ce25cef428c08d2bbc71 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 10 Jan 2014 10:10:08 -0800 Subject: [PATCH] Add parseKeystroke function --- src/key-binding.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/key-binding.coffee b/src/key-binding.coffee index 66a6dc278..12fc07266 100644 --- a/src/key-binding.coffee +++ b/src/key-binding.coffee @@ -12,18 +12,18 @@ class KeyBinding @normalizeKeystroke: (keystroke) -> normalizedKeystroke = keystroke.split(/\s+/).map (keystroke) => - keys = @getParser().parse(keystroke) + keys = @parseKeystroke(keystroke) modifiers = keys[0...-1] modifiers.sort() [modifiers..., _.last(keys)].join('-') normalizedKeystroke.join(' ') - @getParser: -> + @parseKeystroke: (keystroke) -> unless KeyBinding.parser? keystrokePattern = fs.readFileSync(require.resolve('./keystroke-pattern.pegjs'), 'utf8') KeyBinding.parser = PEG.buildParser(keystrokePattern) - KeyBinding.parser + KeyBinding.parser.parse(keystroke) constructor: (source, command, keystroke, selector) -> @source = source