diff --git a/src/command/Menus.js b/src/command/Menus.js index b8b4cac7771..3747909df90 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -525,29 +525,7 @@ define(function (require, exports, module) { var $relativeElement = this._getRelativeMenuItem(relativeID, position); _insertInList($("li#" + StringUtils.jQueryIdEscape(this.id) + " > ul.dropdown-menu"), $menuItem, position, $relativeElement); - } - - // Initialize MenuItem state - if (!menuItem.isDivider) { - if (keyBindings) { - // Add key bindings. The MenuItem listens to the Command object to update MenuItem DOM with shortcuts. - if (!Array.isArray(keyBindings)) { - keyBindings = [keyBindings]; - } - } - - // Note that keyBindings passed during MenuItem creation take precedent over any existing key bindings - KeyBindingManager.addBinding(commandID, keyBindings); - - // Look for existing key bindings - _addExistingKeyBinding(menuItem, commandID); - - menuItem._checkedChanged(); - menuItem._enabledChanged(); - menuItem._nameChanged(); - } - - if (!_isHTMLMenu(this.id)) { + } else { var bindings = KeyBindingManager.getKeyBindings(commandID), binding, bindingStr = "", @@ -575,30 +553,30 @@ define(function (require, exports, module) { brackets.app.addMenuItem(this.id, name, commandID, bindingStr, displayStr, position, relativeID, function (err) { if (err) { console.error("addMenuItem() -- error: " + err + " when adding command: " + commandID); - } else { - // Make sure the name and shortcut are up to date - if (!menuItem.isDivider) { - brackets.app.setMenuTitle(commandID, name, function (err) { - if (err) { - console.error("setMenuTitle() -- error: " + err + " when adding command: " + commandID); - } else { - brackets.app.setMenuItemShortcut( - commandID, - bindingStr, - displayStr, - function (err) { - if (err) { - console.error("setMenuItemShortcut() -- error: " + err + " when adding command: " + commandID); - } - } - ); - } - }); - } } }); menuItem.isNative = true; } + + // Initialize MenuItem state + if (!menuItem.isDivider) { + if (keyBindings) { + // Add key bindings. The MenuItem listens to the Command object to update MenuItem DOM with shortcuts. + if (!Array.isArray(keyBindings)) { + keyBindings = [keyBindings]; + } + } + + // Note that keyBindings passed during MenuItem creation take precedent over any existing key bindings + KeyBindingManager.addBinding(commandID, keyBindings); + + // Look for existing key bindings + _addExistingKeyBinding(menuItem, commandID); + + menuItem._checkedChanged(); + menuItem._enabledChanged(); + menuItem._nameChanged(); + } return menuItem; };