diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee index 3921542ef..e4a551906 100644 --- a/spec/app/pane-spec.coffee +++ b/spec/app/pane-spec.coffee @@ -80,6 +80,10 @@ describe "Pane", -> pane.removeItem(editSession1) expect(pane.itemViews.find('.editor')).not.toExist() + it "calls destroy on the model", -> + pane.removeItem(editSession2) + expect(editSession2.destroyed).toBeTruthy() + describe "pane:show-next-item and pane:show-preview-item", -> it "advances forward/backward through the pane's items, looping around at either end", -> expect(pane.currentItem).toBe view1 @@ -91,3 +95,9 @@ describe "Pane", -> expect(pane.currentItem).toBe editSession2 pane.trigger 'pane:show-next-item' expect(pane.currentItem).toBe view1 + + describe ".remove()", -> + it "destroys all the pane's items", -> + pane.remove() + expect(editSession1.destroyed).toBeTruthy() + expect(editSession2.destroyed).toBeTruthy() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 03f7766ed..dc4bddd85 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -498,7 +498,7 @@ class Editor extends View @editSessions.push(editSession) @closedEditSessions = @closedEditSessions.filter ({path})-> path isnt editSession.getPath() - editSession.on 'destroyed', => @editSessionDestroyed(editSession) +# editSession.on 'destroyed', => @editSessionDestroyed(editSession) @trigger 'editor:edit-session-added', [editSession, index] index diff --git a/src/app/pane.coffee b/src/app/pane.coffee index dd9a4ac10..774654b76 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -64,6 +64,7 @@ class Pane extends View removeItem: (item) -> @showNextItem() if item is @currentItem and @items.length > 1 _.remove(@items, item) + item.destroy?() @cleanupItemView(item) cleanupItemView: (item) -> @@ -135,6 +136,9 @@ class Pane extends View parentAxis.replaceWith(sibling) rootView?.adjustPaneDimensions() + afterRemove: -> + item.destroy?() for item in @getItems() + buildPaneAxis: (axis) -> switch axis when 'row' then new PaneRow