mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Don't close permanent dock items
This commit is contained in:
@@ -2463,7 +2463,7 @@ i = /test/; #FIXME\
|
||||
waitsForPromise(() => atom.workspace.open())
|
||||
})
|
||||
|
||||
it('closes the active pane item, or the active pane if it is empty, or the current window if there is only the empty root pane', () => {
|
||||
it('closes the active pane item, or the active pane if it is empty, or the current window if there is only the empty root pane', async () => {
|
||||
atom.config.set('core.destroyEmptyPanes', false)
|
||||
|
||||
const pane1 = atom.workspace.getActivePane()
|
||||
@@ -2484,10 +2484,28 @@ i = /test/; #FIXME\
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
expect(atom.workspace.getCenter().getPanes().length).toBe(1)
|
||||
expect(pane1.getItems().length).toBe(0)
|
||||
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
expect(atom.workspace.getCenter().getPanes().length).toBe(1)
|
||||
|
||||
await atom.workspace.open({
|
||||
getTitle: () => 'Permanent Dock Item',
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation: () => 'left',
|
||||
isPermanentDockItem: () => true
|
||||
})
|
||||
await atom.workspace.open({
|
||||
getTitle: () => 'Impermanent Dock Item',
|
||||
element: document.createElement('div'),
|
||||
getDefaultLocation: () => 'left'
|
||||
})
|
||||
|
||||
expect(atom.workspace.getLeftDock().getPaneItems().length).toBe(2)
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
expect(atom.workspace.getLeftDock().getPaneItems().length).toBe(1)
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
expect(atom.workspace.getLeftDock().getPaneItems().length).toBe(1)
|
||||
expect(atom.close).not.toHaveBeenCalled()
|
||||
|
||||
atom.workspace.getCenter().activate()
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
expect(atom.close).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -602,6 +602,7 @@ class Pane
|
||||
destroyItem: (item) ->
|
||||
index = @items.indexOf(item)
|
||||
if index isnt -1
|
||||
return false if @getContainer()?.getLocation() isnt 'center' and item.isPermanentDockItem?()
|
||||
@emitter.emit 'will-destroy-item', {item, index}
|
||||
@container?.willDestroyPaneItem({item, index, pane: this})
|
||||
if @promptToSaveItem(item)
|
||||
|
||||
Reference in New Issue
Block a user