Merge branch 'master' into v2

This commit is contained in:
CHaBou 2017-09-17 23:08:33 +02:00
commit f8c19b0ef2
No known key found for this signature in database
GPG key ID: EF8D073B729A0B33
5 changed files with 21 additions and 71 deletions

View file

@ -1,5 +1,4 @@
const {readFileSync} = require('fs');
const {normalize} = require('../utils/keymaps-normalize');
const {defaultPlatformKeyPath} = require('./paths');
const commands = {};
@ -8,7 +7,7 @@ const keys = {};
const _setKeysForCommands = function(keymap) {
for (const command in keymap) {
if (command) {
commands[command] = normalize(keymap[command]);
commands[command] = keymap[command].toLowerCase();
}
}
};
@ -39,8 +38,8 @@ const _extend = function(customsKeys) {
if (customsKeys) {
for (const command in customsKeys) {
if (command) {
commands[command] = normalize(customsKeys[command]);
keys[normalize(customsKeys[command])] = command;
commands[command] = customsKeys[command];
keys[customsKeys[command]] = command;
}
}
}

View file

@ -1,27 +0,0 @@
const {getKeymaps} = require('../config/keymaps');
const normalize = keybinding => {
function sortAlphabetically(a, b) {
return a.localeCompare(b);
}
return keybinding
.toLowerCase()
.split('+')
.sort(sortAlphabetically)
.join('+');
};
const findCommandByKeys = (keys, commands) => {
return commands[normalize(keys)];
};
const getCommand = keys => {
return findCommandByKeys(keys, getKeymaps().keys);
};
module.exports = {
normalize,
findCommandByKeys,
getCommand
};