mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 16:08:24 +03:00
Support moving an edit session's editor index
This commit is contained in:
parent
5abf17e93b
commit
a104e67acd
@ -2588,3 +2588,29 @@ describe "Editor", ->
|
||||
expect(buffer.lineForRow(14)).toBe ''
|
||||
expect(buffer.lineForRow(15)).toBeUndefined()
|
||||
expect(editor.getCursorBufferPosition()).toEqual [14, 0]
|
||||
|
||||
describe ".moveEditSessionAtIndex(fromIndex, toIndex)", ->
|
||||
it "updates the edit session order", ->
|
||||
jsPath = editor.getPath()
|
||||
rootView.open("sample.txt")
|
||||
txtPath = editor.getPath()
|
||||
expect(editor.editSessions[0].getPath()).toBe jsPath
|
||||
expect(editor.editSessions[1].getPath()).toBe txtPath
|
||||
editor.moveEditSessionAtIndex(0, 1)
|
||||
expect(editor.editSessions[0].getPath()).toBe txtPath
|
||||
expect(editor.editSessions[1].getPath()).toBe jsPath
|
||||
|
||||
it "fires an editor:edit-session-order-changed event", ->
|
||||
eventHandler = jasmine.createSpy("eventHandler")
|
||||
rootView.open("sample.txt")
|
||||
editor.on "editor:edit-session-order-changed", eventHandler
|
||||
editor.moveEditSessionAtIndex(0, 1)
|
||||
expect(eventHandler).toHaveBeenCalled()
|
||||
|
||||
it "sets the moved session as the editor's active session", ->
|
||||
jsPath = editor.getPath()
|
||||
rootView.open("sample.txt")
|
||||
txtPath = editor.getPath()
|
||||
expect(editor.activeEditSession.getPath()).toBe txtPath
|
||||
editor.moveEditSessionAtIndex(0, 1)
|
||||
expect(editor.activeEditSession.getPath()).toBe jsPath
|
||||
|
@ -549,6 +549,12 @@ class Editor extends View
|
||||
"Cancel"
|
||||
)
|
||||
|
||||
moveEditSessionAtIndex: (fromIndex, toIndex) ->
|
||||
editSession = @editSessions.splice(fromIndex, 1)
|
||||
@editSessions.splice(toIndex, 0, editSession[0])
|
||||
@trigger 'editor:edit-session-order-changed'
|
||||
@setActiveEditSessionIndex(toIndex)
|
||||
|
||||
transferEditSessionAtIndex: (fromIndex, toIndex, toEditor) ->
|
||||
toEditor.editSessions.splice(toIndex, 0, @editSessions.splice(fromIndex, 1)[0])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user