mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
When splitting an editor only the active edit session is copied to the new editor.
This commit is contained in:
@@ -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", ->
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user