Destroy remaining items when a pane is destroyed

This commit is contained in:
Nathan Sobo
2014-01-09 16:06:02 -07:00
parent 073ea84d69
commit 4dcba4bb27
2 changed files with 8 additions and 1 deletions

View File

@@ -107,9 +107,15 @@ describe "PaneModel", ->
[pane1, container] = []
beforeEach ->
pane1 = new PaneModel(items: ["A"])
pane1 = new PaneModel(items: [new Model, new Model])
container = new PaneContainerModel(root: pane1)
it "destroys the pane's destroyable items", ->
[item1, item2] = pane1.items
pane1.destroy()
expect(item1.isDestroyed()).toBe true
expect(item2.isDestroyed()).toBe true
describe "if the pane's parent has more than two children", ->
it "removes the pane from its parent", ->
pane2 = pane1.splitRight()

View File

@@ -142,6 +142,7 @@ class PaneModel extends Model
# Private: Called by model superclass
destroyed: ->
item.destroy?() for item in @items.slice()
@parent.focusNextPane() if @focused
# Public: Prompt the user to save the given item.