Serialize project in window state

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-06-25 15:53:42 -07:00
committed by Nathan Sobo
parent 89192c2ee2
commit cd4622fbeb
2 changed files with 18 additions and 5 deletions

View File

@@ -15,6 +15,10 @@ BufferedProcess = require 'buffered-process'
# of directories and files that you can operate on.
module.exports =
class Project
registerDeserializer(this)
@deserialize: (state) -> new Project(state.path)
@openers: []
@registerOpener: (opener) ->
@@ -45,6 +49,10 @@ class Project
@editSessions = []
@buffers = []
serialize: ->
deserializer: 'Project'
path: @getPath()
# Retrieves the project path.
#
# Returns a {String}.

View File

@@ -116,14 +116,19 @@ window.deserializeEditorWindow = ->
Project = require 'project'
Git = require 'git'
{initialPath} = atom.getLoadSettings()
windowState = atom.getWindowState()
atom.packageStates = windowState.getObject('packageStates') ? {}
window.project = new Project(initialPath)
window.rootView = deserialize(windowState.get('rootView')) ? new RootView
windowState.set('rootView', window.rootView.serialize())
window.project = deserialize(windowState.get('project'))
unless window.project?
window.project = new Project(atom.getLoadSettings().initialPath)
windowState.set('project', window.project.serialize())
window.rootView = deserialize(windowState.get('rootView'))
unless window.rootView?
window.rootView = new RootView()
windowState.set('rootView', window.rootView.serialize())
$(rootViewParentSelector).append(rootView)