diff --git a/src/app/menu-bar.coffee b/src/app/menu-bar.coffee index a05b461d7..76fa9480a 100644 --- a/src/app/menu-bar.coffee +++ b/src/app/menu-bar.coffee @@ -2,7 +2,7 @@ ipc = require 'ipc' module.exports = class MenuBar - @show: -> + @show: (keyBindingsByCommand) -> atomMenu = label: 'Atom' submenu: [ @@ -67,18 +67,17 @@ class MenuBar label: '\uD83D\uDC80' # Skull emoji submenu: [ { label: 'In Development Mode', enabled: false } ] - @addKeyBindings(menu) + @addKeyBindings(menu, keyBindingsByCommand) ipc.sendChannel 'build-menu-bar-from-template', menu - @addKeyBindings: (menuItems) -> + @addKeyBindings: (menuItems, keyBindingsByCommand) -> for menuItem in menuItems if menuItem.command - menuItem.accelerator = @acceleratorForCommand(menuItem.command) - @addKeyBindings(menuItem.submenu) if menuItem.submenu + menuItem.accelerator = @acceleratorForCommand(menuItem.command, keyBindingsByCommand) + @addKeyBindings(menuItem.submenu, keyBindingsByCommand) if menuItem.submenu - @acceleratorForCommand: (command) -> - keyBindings = keymap.keyBindingsForCommand(command) - keyBinding = keyBindings[0] + @acceleratorForCommand: (command, keyBindingsByCommand) -> + keyBinding = keyBindingsByCommand[command]?[0] return null unless keyBinding modifiers = keyBinding.split('-') diff --git a/src/binding-set.coffee b/src/binding-set.coffee index 0a3723fb0..5bc08f33a 100644 --- a/src/binding-set.coffee +++ b/src/binding-set.coffee @@ -28,12 +28,6 @@ class BindingSet return command if event.keystrokes == keystrokes null - keyBindingsForCommand: (desiredCommand) -> - keyBindings = [] - for keystrokes, command of @commandsByKeystrokes - keyBindings.push(keystrokes) if command == desiredCommand - keyBindings - matchesKeystrokePrefix: (event) -> eventKeystrokes = event.keystrokes.split(' ') for keystrokes, command of @commandsByKeystrokes diff --git a/src/keymap.coffee b/src/keymap.coffee index 9f77fac51..81825a7dd 100644 --- a/src/keymap.coffee +++ b/src/keymap.coffee @@ -163,12 +163,6 @@ class Keymap [modifiers..., key].join('-') - keyBindingsForCommand: (command) -> - keyBindings = [] - for bindingSet in @bindingSets - keyBindings = keyBindings.concat(bindingSet.keyBindingsForCommand(command)) - keyBindings - toObject: -> keyBindingsForCommands = {} for bindingSet in @bindingSets diff --git a/src/window.coffee b/src/window.coffee index d4404620a..06e4701db 100644 --- a/src/window.coffee +++ b/src/window.coffee @@ -55,7 +55,7 @@ window.startEditorWindow = -> atom.activatePackages() keymap.loadUserKeymaps() atom.requireUserInitScript() - MenuBar.show() + MenuBar.show(keymap.toObject()) $(window).on 'unload', -> unloadEditorWindow(); false atom.show() atom.focus()