Skip to content

Commit dfcd547

Browse files
author
Colin Grant
committed
Fix MacOS browser menu keybinding display
1 parent c6ac473 commit dfcd547

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/core/src/browser/keybinding.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,9 @@ export class KeybindingRegistry {
314314
* @param keybinding the keybinding
315315
* @param separator the separator to be used to stringify {@link KeyCode}s that are part of the {@link KeySequence}
316316
*/
317-
acceleratorFor(keybinding: common.Keybinding, separator: string = ' '): string[] {
317+
acceleratorFor(keybinding: common.Keybinding, separator: string = ' ', asciiOnly = false): string[] {
318318
const bindingKeySequence = this.resolveKeybinding(keybinding);
319-
return this.acceleratorForSequence(bindingKeySequence, separator);
319+
return this.acceleratorForSequence(bindingKeySequence, separator, asciiOnly);
320320
}
321321

322322
/**
@@ -325,8 +325,8 @@ export class KeybindingRegistry {
325325
* @param keySequence the keysequence
326326
* @param separator the separator to be used to stringify {@link KeyCode}s that are part of the {@link KeySequence}
327327
*/
328-
acceleratorForSequence(keySequence: KeySequence, separator: string = ' '): string[] {
329-
return keySequence.map(keyCode => this.acceleratorForKeyCode(keyCode, separator));
328+
acceleratorForSequence(keySequence: KeySequence, separator: string = ' ', asciiOnly = false): string[] {
329+
return keySequence.map(keyCode => this.acceleratorForKeyCode(keyCode, separator, asciiOnly));
330330
}
331331

332332
/**
@@ -337,7 +337,9 @@ export class KeybindingRegistry {
337337
* @param asciiOnly if `true`, no special characters will be substituted into the string returned. Ensures correct keyboard shortcuts in Electron menus.
338338
*/
339339
acceleratorForKeyCode(keyCode: KeyCode, separator: string = ' ', asciiOnly = false): string {
340-
return this.componentsForKeyCode(keyCode, asciiOnly).join(separator);
340+
const accelerator = this.componentsForKeyCode(keyCode, asciiOnly).join(separator);
341+
console.log('SENTINEL FOR GETTING AN ACCELERATOR', accelerator, new Error());
342+
return accelerator;
341343
}
342344

343345
componentsForKeyCode(keyCode: KeyCode, asciiOnly = false): string[] {

packages/core/src/browser/menu/browser-menu-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ export class MenuCommandRegistry extends PhosphorCommandRegistry {
479479
// Only consider the first keybinding.
480480
if (bindings.length) {
481481
const binding = bindings[0];
482-
const keys = keybindingRegistry.acceleratorFor(binding);
482+
const keys = keybindingRegistry.acceleratorFor(binding, ' ', true);
483483
this.addKeyBinding({
484484
command: id,
485485
keys,

0 commit comments

Comments
 (0)