mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Add the 'editor:edit-session-removed' event to Editor
This commit is contained in:
@@ -152,7 +152,7 @@ describe "Editor", ->
|
||||
expect(otherEditSession.buffer.subscriptionCount()).toBe 0
|
||||
|
||||
describe "when 'close' is triggered", ->
|
||||
it "closes active edit session and loads next edit session", ->
|
||||
it "closes the active edit session and loads next edit session", ->
|
||||
editor.edit(rootView.project.buildEditSessionForPath())
|
||||
editSession = editor.activeEditSession
|
||||
spyOn(editSession.buffer, 'isModified').andReturn false
|
||||
@@ -163,6 +163,19 @@ describe "Editor", ->
|
||||
expect(editor.remove).not.toHaveBeenCalled()
|
||||
expect(editor.getBuffer()).toBe buffer
|
||||
|
||||
it "triggers the 'editor:edit-session-removed' event with the edit session and its former index", ->
|
||||
editor.edit(rootView.project.buildEditSessionForPath())
|
||||
editSession = editor.activeEditSession
|
||||
index = editor.getActiveEditSessionIndex()
|
||||
spyOn(editSession.buffer, 'isModified').andReturn false
|
||||
|
||||
editSessionRemovedHandler = jasmine.createSpy('editSessionRemovedHandler')
|
||||
editor.on 'editor:edit-session-removed', editSessionRemovedHandler
|
||||
editor.trigger "core:close"
|
||||
|
||||
expect(editSessionRemovedHandler).toHaveBeenCalled()
|
||||
expect(editSessionRemovedHandler.argsForCall[0][1..2]).toEqual [editSession, index]
|
||||
|
||||
it "calls remove on the editor if there is one edit session and mini is false", ->
|
||||
editSession = editor.activeEditSession
|
||||
expect(editor.mini).toBeFalsy()
|
||||
|
||||
@@ -399,9 +399,11 @@ class Editor extends View
|
||||
@remove()
|
||||
else
|
||||
editSession = @activeEditSession
|
||||
index = @getActiveEditSessionIndex()
|
||||
@loadPreviousEditSession()
|
||||
_.remove(@editSessions, editSession)
|
||||
editSession.destroy()
|
||||
@trigger 'editor:edit-session-removed', [editSession, index]
|
||||
|
||||
loadNextEditSession: ->
|
||||
nextIndex = (@getActiveEditSessionIndex() + 1) % @editSessions.length
|
||||
|
||||
Reference in New Issue
Block a user