2017-09-19 15:36:06 -08:00
|
|
|
// This function receives a keymap in any key order and returns
|
|
|
|
|
// the same keymap alphatetically sorted by the clients locale.
|
|
|
|
|
// eg.: cmd+alt+o -> alt+cmd+o
|
|
|
|
|
// We do this in order to normalize what the user defined to what we
|
|
|
|
|
// internally parse. By doing this, you can set your keymaps in any given order
|
|
|
|
|
// eg.: alt+cmd+o, cmd+alt+o, o+alt+cmd, etc. #2195
|
|
|
|
|
module.exports = keybinding => {
|
|
|
|
|
function sortAlphabetically(a, b) {
|
|
|
|
|
return a.localeCompare(b);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-19 15:39:55 -08:00
|
|
|
return keybinding
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.split('+')
|
|
|
|
|
.sort(sortAlphabetically)
|
|
|
|
|
.join('+');
|
2017-09-19 15:36:06 -08:00
|
|
|
};
|