Serialize root view state to a string of JSON when storing it on the window upon refresh

This avoid situations where arrays in the window state pointed to a different constructor than the current context's Array constructor.
This commit is contained in:
Corey Johnson & Nathan Sobo
2012-06-15 15:32:27 -06:00
parent 4a35427db3
commit 951f76f2bf
3 changed files with 3 additions and 3 deletions

View File

@@ -53,7 +53,7 @@ describe "Window", ->
expect(atom.rootViewStates[$windowNumber]).toBeUndefined()
expectedState = window.rootView.serialize()
$(window).trigger 'beforeunload'
expect(atom.rootViewStates[$windowNumber]).toEqual expectedState
expect(atom.rootViewStates[$windowNumber]).toEqual JSON.stringify(expectedState)
it "unsubscribes from all buffers", ->
editor1 = rootView.activeEditor()

View File

@@ -85,7 +85,7 @@ class RootView extends View
extension.activate(this, @extensionStates[extension.name])
deactivate: ->
atom.rootViewStates[$windowNumber] = @serialize()
atom.rootViewStates[$windowNumber] = JSON.stringify(@serialize())
extension.deactivate?() for name, extension of @extensions
@remove()

View File

@@ -41,7 +41,7 @@ windowAdditions =
attachRootView: (pathToOpen) ->
rootViewState = atom.rootViewStates[$windowNumber]
if rootViewState
@rootView = RootView.deserialize(rootViewState)
@rootView = RootView.deserialize(JSON.parse(rootViewState))
else
@rootView = new RootView(pathToOpen)
@rootView.open() unless pathToOpen