diff --git a/spec/project-spec.coffee b/spec/project-spec.coffee index b12d8683e..fc48ca191 100644 --- a/spec/project-spec.coffee +++ b/spec/project-spec.coffee @@ -62,6 +62,22 @@ describe "Project", -> expect(project.getEditSessions()[0]).toBe editSession1 expect(project.getEditSessions()[1]).toBe editSession2 + describe "when an edit session is copied", -> + it "emits an 'edit-session-created' event and stores the edit session", -> + handler = jasmine.createSpy('editSessionCreatedHandler') + project.on 'edit-session-created', handler + + editSession1 = project.openSync("a") + expect(handler.callCount).toBe 1 + expect(project.getEditSessions().length).toBe 1 + expect(project.getEditSessions()[0]).toBe editSession1 + + editSession2 = editSession1.copy() + expect(handler.callCount).toBe 2 + expect(project.getEditSessions().length).toBe 2 + expect(project.getEditSessions()[0]).toBe editSession1 + expect(project.getEditSessions()[1]).toBe editSession2 + describe ".openSync(path)", -> [fooOpener, barOpener, absolutePath, newBufferHandler, newEditSessionHandler] = [] beforeEach -> diff --git a/src/edit-session.coffee b/src/edit-session.coffee index a23427ce2..2cc8397e2 100644 --- a/src/edit-session.coffee +++ b/src/edit-session.coffee @@ -162,6 +162,7 @@ class EditSession newEditSession.setScrollLeft(@getScrollLeft()) for marker in @findMarkers(editSessionId: @id) marker.copy(editSessionId: newEditSession.id, preserveFolds: true) + project.addEditSession(newEditSession) newEditSession # Public: Retrieves the filename of the open file.