Skip to content

Commit

Permalink
Serialize root view state to a string of JSON when storing it on the …
Browse files Browse the repository at this point in the history
…window upon refresh

This avoid situations where arrays in the window state pointed to a different constructor than the current context's Array constructor.
  • Loading branch information
probablycorey-and-nathan committed Jun 15, 2012
1 parent 4a35427 commit 951f76f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spec/app/window-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/app/root-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/app/window.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 951f76f

Please sign in to comment.