diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 6e4a6d696..0628042f4 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -40,6 +40,9 @@ describe "Editor", -> expect(newEditor.buffer).toBe editor.buffer expect(newEditor.getCursorScreenPosition()).toEqual editor.getCursorScreenPosition() + expect(newEditor.editSessions[0]).toEqual(editor.editSessions[0]) + expect(newEditor.editSessions[0]).not.toBe(editor.editSessions[0]) + describe "text rendering", -> it "creates a line element for each line in the buffer with the html-escaped text of the line", -> expect(editor.lines.find('.line').length).toEqual(buffer.numLines()) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 5de308071..36ac30709 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -38,6 +38,7 @@ class Editor extends View isFocused: false softTabs: true tabText: ' ' + editSessions: null @deserialize: (viewState) -> new Editor(viewState) @@ -64,7 +65,10 @@ class Editor extends View serialize: -> @saveCurrentEditSession() - { viewClass: "Editor", @editSessions, @activeEditSessionIndex, @isFocused } + { viewClass: "Editor", editSessions: @serializeEditSessions(), @activeEditSessionIndex, @isFocused } + + serializeEditSessions: -> + @editSessions.map (session) -> _.clone(session) copy: -> Editor.deserialize(@serialize()) @@ -512,7 +516,7 @@ class Editor extends View return super if keepData @unsubscribeFromBuffer() rootView = @rootView() - if @pane() then @pane.remove() else super + if @pane() then @pane().remove() else super rootView?.focus() unsubscribeFromBuffer: ->