From 9dfa7d9439acda598a497aa3be78b50ccdf44ed7 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Fri, 13 Jul 2012 09:24:14 -0700 Subject: [PATCH] When splitting an editor only the active edit session is copied to the new editor. --- spec/app/editor-spec.coffee | 11 ++++++----- src/app/editor.coffee | 12 ++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 445471590..f88789f89 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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", -> diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 2288251fd..c3fbe71d7 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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()