mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Only destroy an empty panes if 'core.destroyEmptyPanes' is true
This commit is contained in:
@@ -146,19 +146,27 @@ describe "Pane", ->
|
||||
expect(item1.isDestroyed()).toBe false
|
||||
|
||||
describe "when the last item is destroyed", ->
|
||||
it "destroys the pane", ->
|
||||
pane.destroyItem(item) for item in pane.getItems()
|
||||
expect(pane.isDestroyed()).toBe true
|
||||
describe "when the 'core.destroyEmptyPanes' config option is false (the default)", ->
|
||||
it "does not destroy the pane, but leaves it in place with empty items", ->
|
||||
expect(atom.config.get('core.destroyEmptyPanes')).toBe false
|
||||
pane.destroyItem(item) for item in pane.getItems()
|
||||
expect(pane.isDestroyed()).toBe false
|
||||
expect(pane.activeItem).toBeUndefined()
|
||||
|
||||
describe "when the 'core.destroyEmptyPanes' config option is true", ->
|
||||
it "destroys the pane", ->
|
||||
atom.config.set('core.destroyEmptyPanes', true)
|
||||
pane.destroyItem(item) for item in pane.getItems()
|
||||
expect(pane.isDestroyed()).toBe true
|
||||
|
||||
describe "::destroyItems()", ->
|
||||
it "destroys all items and the pane", ->
|
||||
it "destroys all items", ->
|
||||
pane = new Pane(items: [new Item("A"), new Item("B"), new Item("C")])
|
||||
[item1, item2, item3] = pane.items
|
||||
pane.destroyItems()
|
||||
expect(item1.isDestroyed()).toBe true
|
||||
expect(item2.isDestroyed()).toBe true
|
||||
expect(item3.isDestroyed()).toBe true
|
||||
expect(pane.isDestroyed()).toBe true
|
||||
expect(pane.items).toEqual []
|
||||
|
||||
describe "when an item emits a destroyed event", ->
|
||||
@@ -280,11 +288,21 @@ describe "Pane", ->
|
||||
expect(pane2.items).toEqual [item4, item2, item5]
|
||||
|
||||
describe "when the moved item the last item in the source pane", ->
|
||||
it "destroys the pane, but not the item", ->
|
||||
beforeEach ->
|
||||
item5.destroy()
|
||||
pane2.moveItemToPane(item4, pane1, 0)
|
||||
expect(pane2.isDestroyed()).toBe true
|
||||
expect(item4.isDestroyed()).toBe false
|
||||
|
||||
describe "when the 'core.destroyEmptyPanes' config option is false (the default)", ->
|
||||
it "does not destroy the pane or the item", ->
|
||||
pane2.moveItemToPane(item4, pane1, 0)
|
||||
expect(pane2.isDestroyed()).toBe false
|
||||
expect(item4.isDestroyed()).toBe false
|
||||
|
||||
describe "when the 'core.destroyEmptyPanes' config option is true", ->
|
||||
it "destroys the pane, but not the item", ->
|
||||
atom.config.set('core.destroyEmptyPanes', true)
|
||||
pane2.moveItemToPane(item4, pane1, 0)
|
||||
expect(pane2.isDestroyed()).toBe true
|
||||
expect(item4.isDestroyed()).toBe false
|
||||
|
||||
describe "split methods", ->
|
||||
[pane1, container] = []
|
||||
|
||||
@@ -561,7 +561,8 @@ describe "WorkspaceView", ->
|
||||
expect(workspace.getActivePaneItem().getUri()).toBe 'a'
|
||||
|
||||
describe "core:close", ->
|
||||
it "closes the active editor until there are none", ->
|
||||
it "closes the active pane item until isn't one", ->
|
||||
atom.config.set('core.destroyEmptyPanes', true)
|
||||
atom.project.openSync('../sample.txt')
|
||||
expect(atom.workspaceView.getActivePane().getItems()).toHaveLength 1
|
||||
atom.workspaceView.trigger('core:close')
|
||||
|
||||
@@ -14,8 +14,8 @@ class Pane extends Model
|
||||
Serializable.includeInto(this)
|
||||
|
||||
@properties
|
||||
container: null
|
||||
activeItem: null
|
||||
container: undefined
|
||||
activeItem: undefined
|
||||
focused: false
|
||||
|
||||
# Public: Only one pane is considered *active* at a time. A pane is activated
|
||||
@@ -139,11 +139,15 @@ class Pane extends Model
|
||||
removeItem: (item, destroying) ->
|
||||
index = @items.indexOf(item)
|
||||
return if index is -1
|
||||
@activateNextItem() if item is @activeItem and @items.length > 1
|
||||
if item is @activeItem
|
||||
if @items.length is 1
|
||||
@activeItem = undefined
|
||||
else
|
||||
@activateNextItem()
|
||||
@items.splice(index, 1)
|
||||
@emit 'item-removed', item, index, destroying
|
||||
@container?.itemDestroyed(item) if destroying
|
||||
@destroy() if @items.length is 0
|
||||
@destroy() if @items.length is 0 and atom.config.get('core.destroyEmptyPanes')
|
||||
|
||||
# Public: Moves the given item to the specified index.
|
||||
moveItem: (item, newIndex) ->
|
||||
|
||||
@@ -55,6 +55,7 @@ class WorkspaceView extends View
|
||||
themes: ['atom-dark-ui', 'atom-dark-syntax']
|
||||
projectHome: path.join(fs.getHomeDirectory(), 'github')
|
||||
audioBeep: true
|
||||
destroyEmptyPanes: false
|
||||
|
||||
# Private:
|
||||
@content: ->
|
||||
|
||||
Reference in New Issue
Block a user