When splitting an editor only the active edit session is copied to the new editor.

This commit is contained in:
Corey Johnson
2012-07-13 09:24:14 -07:00
parent d44c648d4b
commit 9dfa7d9439
2 changed files with 14 additions and 9 deletions

View File

@@ -356,13 +356,14 @@ describe "Editor", ->
fakePane = { splitUp: jasmine.createSpy('splitUp').andReturn({}), remove: -> }
spyOn(editor, 'pane').andReturn(fakePane)
it "calls the corresponding split method on the containing pane with a copy of the editor", ->
it "calls the corresponding split method on the containing pane with a new editor containing a copy of the active edit session", ->
editor.edit project.open("sample.txt")
editor.splitUp()
expect(fakePane.splitUp).toHaveBeenCalled()
[editorCopy] = fakePane.splitUp.argsForCall[0]
expect(editorCopy.serialize()).toEqual editor.serialize()
expect(editorCopy).not.toBe editor
editorCopy.remove()
[newEditor] = fakePane.splitUp.argsForCall[0]
expect(newEditor.editSessions.length).toEqual 1
expect(newEditor.activeEditSession.buffer).toBe editor.activeEditSession.buffer
newEditor.remove()
describe "when not inside a pane", ->
it "does not split the editor, but doesn't throw an exception", ->

View File

@@ -519,17 +519,21 @@ class Editor extends View
@updateCursorViews()
@updateRenderedLines()
newSplitEditor: ->
editSession = EditSession.deserialize(@activeEditSession.serialize(), this, @rootView())
new Editor { editSession }
splitLeft: ->
@pane()?.splitLeft(@copy()).wrappedView
@pane()?.splitLeft(@newSplitEditor()).wrappedView
splitRight: ->
@pane()?.splitRight(@copy()).wrappedView
@pane()?.splitRight(@newSplitEditor()).wrappedView
splitUp: ->
@pane()?.splitUp(@copy()).wrappedView
@pane()?.splitUp(@newSplitEditor()).wrappedView
splitDown: ->
@pane()?.splitDown(@copy()).wrappedView
@pane()?.splitDown(@newSplitEditor()).wrappedView
pane: ->
@parent('.pane').view()