From e295d19d5158c007de52adcec3aa5d52c3e018e4 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Thu, 28 Jun 2012 13:54:07 -0700 Subject: [PATCH] `Editor.prototype.removeActiveEditSession` calls `destroy` on the removed edit session --- spec/app/editor-spec.coffee | 6 +++++- src/app/editor.coffee | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index f4001b2f0..8828654c2 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -139,17 +139,21 @@ describe "Editor", -> describe "when 'close' is triggered", -> it "closes active edit session and loads next edit session", -> editor.edit(rootView.project.open()) + editSession = editor.activeEditSession + spyOn(editSession, 'destroy').andCallThrough() spyOn(editor, "remove") editor.trigger "close" + expect(editSession.destroy).toHaveBeenCalled() expect(editor.remove).not.toHaveBeenCalled() expect(editor.buffer).toBe buffer it "calls remove on the editor if there is one edit session and mini is false", -> - originalBuffer = editor.buffer + editSession = editor.activeEditSession expect(editor.mini).toBeFalsy() expect(editor.editSessions.length).toBe 1 spyOn(editor, 'remove') editor.trigger 'close' + spyOn(editSession, 'destroy').andCallThrough() expect(editor.remove).toHaveBeenCalled() editor.remove() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index ab229330c..4ebdaa3c9 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -359,6 +359,7 @@ class Editor extends View editSession = @activeEditSession @loadPreviousEditSession() _.remove(@editSessions, editSession) + editSession.destroy() loadNextEditSession: -> nextIndex = (@getActiveEditSessionIndex() + 1) % @editSessions.length