Add 'editor:edit-session-added' event to Editor

This commit is contained in:
Nathan Sobo
2012-11-20 15:43:57 -07:00
parent 16d4698770
commit 4a373a9173
2 changed files with 8 additions and 1 deletions

View File

@@ -193,12 +193,18 @@ describe "Editor", ->
otherEditSession = rootView.project.buildEditSessionForPath()
describe "when the edit session wasn't previously assigned to this editor", ->
it "adds edit session to editor", ->
it "adds edit session to editor and triggers the 'editor:edit-session-added' event", ->
editSessionAddedHandler = jasmine.createSpy('editSessionAddedHandler')
editor.on 'editor:edit-session-added', editSessionAddedHandler
originalEditSessionCount = editor.editSessions.length
editor.edit(otherEditSession)
expect(editor.activeEditSession).toBe otherEditSession
expect(editor.editSessions.length).toBe originalEditSessionCount + 1
expect(editSessionAddedHandler).toHaveBeenCalled()
expect(editSessionAddedHandler.argsForCall[0][1]).toBe otherEditSession
describe "when the edit session was previously assigned to this editor", ->
it "restores the previous edit session associated with the editor", ->
previousEditSession = editor.activeEditSession

View File

@@ -388,6 +388,7 @@ class Editor extends View
if index == -1
index = @editSessions.length
@editSessions.push(editSession)
@trigger 'editor:edit-session-added', editSession
@setActiveEditSessionIndex(index)