emacs: fix bindKey
register all partial key combos as null commands to be able to activate key combos with arbitrary length Example: if keyPart is "C-c C-l t" then "C-c C-l t" will get command assigned and "C-c" and "C-c C-l" will get a null command assigned
This commit is contained in:
parent
0ea9428cd8
commit
a16380eaea
1 changed files with 14 additions and 5 deletions
|
|
@ -202,12 +202,21 @@ exports.handler.bindKey = function(key, command) {
|
|||
key.split("|").forEach(function(keyPart) {
|
||||
keyPart = keyPart.toLowerCase();
|
||||
ckb[keyPart] = command;
|
||||
keyPart = keyPart.split(" ")[0];
|
||||
if (!ckb[keyPart])
|
||||
ckb[keyPart] = "null";
|
||||
// register all partial key combos as null commands
|
||||
// to be able to activate key combos with arbitrary length
|
||||
// Example: if keyPart is "C-c C-l t" then "C-c C-l t" will
|
||||
// get command assigned and "C-c" and "C-c C-l" will get
|
||||
// a null command assigned in this.commmandKeyBinding. For
|
||||
// the lookup logic see handleKeyboard()
|
||||
var keyParts = keyPart.split(" ").slice(0,-1);
|
||||
keyParts.reduce(function(keyMapKeys, keyPart, i) {
|
||||
var prefix = keyMapKeys[i-1] ? keyMapKeys[i-1] + ' ' : '';
|
||||
return keyMapKeys.concat([prefix + keyPart]);
|
||||
}, []).forEach(function(keyPart) {
|
||||
if (!ckb[keyPart]) ckb[keyPart] = "null";
|
||||
});
|
||||
}, this);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
||||
var editor = data.editor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue