From cd4622fbeb6335c813ca57163447d8964026f637 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki & Nathan Sobo Date: Tue, 25 Jun 2013 15:53:42 -0700 Subject: [PATCH] Serialize project in window state --- src/app/project.coffee | 8 ++++++++ src/app/window.coffee | 15 ++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/app/project.coffee b/src/app/project.coffee index ef053f3d3..9c6c73dca 100644 --- a/src/app/project.coffee +++ b/src/app/project.coffee @@ -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}. diff --git a/src/app/window.coffee b/src/app/window.coffee index f3c3f1373..e02c1a24c 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -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)