diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index 396a497a1..ed357c0fe 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -171,6 +171,7 @@ describe "the `atom` global", -> atom.activatePackage("package-with-menus") + expect(atom.menu.template.length).toBe 2 expect(atom.menu.template[0].label).toBe "Second to Last" expect(atom.menu.template[1].label).toBe "Last" expect(atom.contextMenu.definitionsForElement(element)[0].label).toBe "Menu item 1" diff --git a/spec/fixtures/packages/package-with-menus/menus/menu-3.cson b/spec/fixtures/packages/package-with-menus/menus/menu-3.cson index 83b77430a..932cd4d5b 100644 --- a/spec/fixtures/packages/package-with-menus/menus/menu-3.cson +++ b/spec/fixtures/packages/package-with-menus/menus/menu-3.cson @@ -1,3 +1,7 @@ +'menu': [ + { 'label': 'Second to Last' } +] + 'context-menu': '.test-1': 'Menu item 3': 'command-3' diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 2749e9247..0c4cf377d 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -111,7 +111,6 @@ afterEach -> keymap.bindingSets = bindingSetsToRestore keymap.bindingSetsByFirstKeystroke = bindingSetsByFirstKeystrokeToRestore atom.deactivatePackages() - atom.menu.template = [] window.rootView?.remove?() atom.rootView?.remove?() if atom.rootView isnt window.rootView diff --git a/src/menu-manager.coffee b/src/menu-manager.coffee index 5266e40c1..7fa1f242a 100644 --- a/src/menu-manager.coffee +++ b/src/menu-manager.coffee @@ -43,10 +43,11 @@ class MenuManager # appended to the bottom of existing menus where possible. merge: (menu, item) -> item = _.deepClone(item) - if item.submenu? and match = _.find(menu, (o) -> o.submenu? and o.label == item.label) + + if item.submenu? and match = _.find(menu, (i) -> i.submenu? and i.label == item.label) @merge(match.submenu, i) for i in item.submenu else - menu.push(item) + menu.push(item) unless _.find(menu, (i) -> i.label == item.label) # Private sendToBrowserProcess: (template, keystrokesByCommand) ->