mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Fix #2195: normalizing keybindings using localeCompare to include non english keyboards as well
13 lines
551 B
JavaScript
13 lines
551 B
JavaScript
// 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);
|
|
}
|
|
|
|
return keybinding.toLowerCase().split('+').sort(sortAlphabetically).join('+');
|
|
};
|