Ensure that Editor.proto.serialize returns a copy of each edit session

This commit is contained in:
Nathan Sobo
2012-04-13 14:29:58 -06:00
parent 65c624f2bf
commit c673c5114e
2 changed files with 9 additions and 2 deletions

View File

@@ -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: ->