From 967aa7bf31998f667616f19f9b83e409340b66d1 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 2 Oct 2016 09:01:29 +0100 Subject: Rework key-sequence parsing. This reworks the parsing of key sequences like `x`: Advantages over the status quo: - Parses key sequences in one only place (previously two), - Removes two hideous regular expression. - Admits multi-modifier bindings (like ``). - Adds more (and better) tests. - (And it should be easier to maintain.) Replaces #2210 (this also simplifies key parsing substantially). --- lib/keyboard_utils.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/keyboard_utils.coffee') diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee index dabf864d..f0e791d4 100644 --- a/lib/keyboard_utils.coffee +++ b/lib/keyboard_utils.coffee @@ -111,9 +111,10 @@ KeyboardUtils = modifiers = [] keyChar = keyChar.toUpperCase() if event.shiftKey - modifiers.push "m" if event.metaKey - modifiers.push "c" if event.ctrlKey + # These must be in alphabetical order (to match the sorted modifier order in Commands.normalizeKey). modifiers.push "a" if event.altKey + modifiers.push "c" if event.ctrlKey + modifiers.push "m" if event.metaKey keyChar = [modifiers..., keyChar].join "-" if 1 < keyChar.length then "<#{keyChar}>" else keyChar -- cgit v1.2.3