@@ -1704,9 +1704,24 @@ define(function (require, exports, module) {
17041704
17051705 function _getNormalisedKeyMap ( keyMap ) {
17061706 const normalisedKeyMap = { } ;
1707+ const normalisedKeyMapCounts = { } ;
1708+ // if the supplied keymap has duplicates, we have to retain them as is for error dialogs later. Eg:
1709+ // { "ctrl-2": "file.newFile", "Ctrl-2": "navigate.previousMatch", // observe case of Ctrl here
1710+ // "Ctrl-Alt-4": "view.toggleSidebar", "Alt-Ctrl-4": "view.toggleSidebar"}
1711+ for ( let key of Object . keys ( keyMap ) ) {
1712+ const normalisedKey = normalizeKeyDescriptorString ( key ) ;
1713+ normalisedKeyMapCounts [ normalisedKey ] = ( normalisedKeyMapCounts [ normalisedKey ] || 0 ) + 1 ;
1714+ }
17071715 for ( let key of Object . keys ( keyMap ) ) {
17081716 try {
1709- normalisedKeyMap [ normalizeKeyDescriptorString ( key ) ] = keyMap [ key ] ;
1717+ const normalisedKey = normalizeKeyDescriptorString ( key ) ;
1718+ if ( normalisedKeyMapCounts [ normalisedKey ] === 1 ) {
1719+ normalisedKeyMap [ normalisedKey ] = keyMap [ key ] ;
1720+ } else {
1721+ // if we are here, it means the supplied keymap has non-normalised duplicates.
1722+ // in case of duplicates, we will keep the keys as is in the map for the error dialogs to kick in.
1723+ normalisedKeyMap [ key ] = keyMap [ key ] ;
1724+ }
17101725 } catch ( e ) {
17111726 console . error ( "Error normalising user keymap key: " , key , e ) ;
17121727 // we will still inject the key with error as so that the error dialogs will come up as expected.
0 commit comments