mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-08 16:19:17 +03:00
Prevent adjacent menu separators
This commit is contained in:
parent
eb929cb7a2
commit
4a0c5aaa70
@ -82,13 +82,15 @@ describe "ContextMenuManager", ->
|
|||||||
disposable1.dispose()
|
disposable1.dispose()
|
||||||
expect(contextMenu.templateForElement(grandchild)).toEqual [{label: 'A', command: 'd'}]
|
expect(contextMenu.templateForElement(grandchild)).toEqual [{label: 'A', command: 'd'}]
|
||||||
|
|
||||||
it "allows multiple separators", ->
|
it "allows multiple separators, but not adjacent to each other", ->
|
||||||
contextMenu.add
|
contextMenu.add
|
||||||
'.grandchild': [
|
'.grandchild': [
|
||||||
{label: 'A', command: 'a'},
|
{label: 'A', command: 'a'},
|
||||||
{type: 'separator'},
|
{type: 'separator'},
|
||||||
|
{type: 'separator'},
|
||||||
{label: 'B', command: 'b'},
|
{label: 'B', command: 'b'},
|
||||||
{type: 'separator'},
|
{type: 'separator'},
|
||||||
|
{type: 'separator'},
|
||||||
{label: 'C', command: 'c'}
|
{label: 'C', command: 'c'}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ merge = (menu, item, itemSpecificity=Infinity) ->
|
|||||||
else if itemSpecificity
|
else if itemSpecificity
|
||||||
unless itemSpecificity < ItemSpecificities.get(matchingItem)
|
unless itemSpecificity < ItemSpecificities.get(matchingItem)
|
||||||
menu[matchingItemIndex] = item
|
menu[matchingItemIndex] = item
|
||||||
else
|
else unless item.type is 'separator' and _.last(menu)?.type is 'separator'
|
||||||
menu.push(item)
|
menu.push(item)
|
||||||
|
|
||||||
unmerge = (menu, item) ->
|
unmerge = (menu, item) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user