mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Ensure that Editor.proto.serialize returns a copy of each edit session
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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: ->
|
||||
|
||||
Reference in New Issue
Block a user