diff --git a/src/app/atom.coffee b/src/app/atom.coffee index 8189c83eb..ec9246539 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -13,6 +13,25 @@ _.extend atom, loadedThemes: [] pendingBrowserProcessCallbacks: {} loadedPackages: [] + activatedAtomPackages: [] + atomPackageStates: {} + + activateAtomPackage: (pack) -> + @activatedAtomPackages.push(pack) + pack.packageMain.activate(@atomPackageStates[pack.name]) + + deactivateAtomPackages: -> + pack.packageMain.deactivate?() for pack in @activatedAtomPackages + @activatedAtomPackages = [] + + serializeAtomPackages: -> + packageStates = {} + for pack in @activatedAtomPackages + try + packageStates[pack.name] = pack.packageMain.serialize?() + catch e + console?.error("Exception serializing '#{pack.name}' package's module\n", e.stack) + packageStates loadPackage: (name, options) -> packagePath = _.find @getPackagePaths(), (packagePath) -> fs.base(packagePath) == name diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 86525ed47..909ddc879 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -29,18 +29,18 @@ class RootView extends View else projectOrPathToOpen = projectPath # This will migrate people over to the new project serialization scheme. It should be removed eventually. - rootView = new RootView(projectOrPathToOpen , packageStates: packageStates, suppressOpen: true) + atom.atomPackageStates = packageStates ? {} + + rootView = new RootView(projectOrPathToOpen , suppressOpen: true) rootView.setRootPane(rootView.deserializeView(panesViewState)) if panesViewState rootView packages: null - packageStates: null title: null pathToOpenIsFile: false - initialize: (projectOrPathToOpen, { @packageStates, suppressOpen } = {}) -> + initialize: (projectOrPathToOpen, { suppressOpen } = {}) -> window.rootView = this - @packageStates ?= {} @packages = [] @viewClasses = { "Pane": Pane, @@ -263,18 +263,10 @@ class RootView extends View @project.eachBuffer(callback) activatePackage: (pack) -> - @packages.push(pack) - pack.packageMain.activate(@packageStates[pack.name]) + atom.activateAtomPackage(pack) deactivatePackages: -> - pack.packageMain.deactivate?() for pack in @packages - @packages = [] + atom.deactivateAtomPackages() serializePackages: -> - packageStates = {} - for pack in @packages - try - packageStates[pack.name] = pack.packageMain.serialize?() - catch e - console?.error("Exception serializing '#{name}' package's module\n", e.stack) - packageStates + atom.serializeAtomPackages() diff --git a/src/app/window.coffee b/src/app/window.coffee index c71d381c8..901c6dea8 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -37,8 +37,8 @@ windowAdditions = # Note: RootView assigns itself on window on initialization so that # window.rootView is available when loading user configuration attachRootView: (pathToOpen) -> - if rootViewState = atom.getRootViewStateForPath(pathToOpen) - RootView.deserialize(rootViewState) + if pathState = atom.getRootViewStateForPath(pathToOpen) + RootView.deserialize(pathState) else new RootView(pathToOpen)