mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add 'editor:edit-session-added' event to Editor
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user