From 01b7c4a866321f1bc5209d2257fe92960034c0fa Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 5 Mar 2013 00:03:11 +0400 Subject: [PATCH] do not throw error for key-chains (e.g Ctrl-B Command-Up) --- lib/ace/keyboard/hash_handler.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/ace/keyboard/hash_handler.js b/lib/ace/keyboard/hash_handler.js index 9f0d7128..e56b0b13 100644 --- a/lib/ace/keyboard/hash_handler.js +++ b/lib/ace/keyboard/hash_handler.js @@ -121,10 +121,14 @@ function HashHandler(config, platform) { var key = typeof binding == "string" ? binding: binding[this.platform]; this.bindKey(key, command); }; - - // accepts keys in the form ctrl+Enter or ctrl-Enter - // keys without modifiers or shift only + + // accepts keys in the form ctrl+Enter or ctrl-Enter + // keys without modifiers or shift only this.parseKeys = function(keys) { + // todo support keychains + if (keys.indexOf(" ") != -1) + keys = keys.split(/\s+/).pop(); + var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x}); var key = parts.pop(); @@ -139,8 +143,11 @@ function HashHandler(config, platform) { var hashId = 0; for (var i = parts.length; i--;) { var modifier = keyUtil.KEY_MODS[parts[i]]; - if (modifier == null) - throw "invalid modifier " + parts[i] + " in " + keys; + if (modifier == null) { + if (typeof console != "undefined") + console.error("invalid modifier " + parts[i] + " in " + keys); + return false; + } hashId |= modifier; } return {key: key, hashId: hashId};