mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Serialize package states independently of RootView
Previously, package specs needed to deactivate the root view to test their package serialization. Now, specs can just deactivate and then reactivate the package, relying on serialization infrastructure that's independent of the lifecycle of the RootView.
This commit is contained in:
@@ -27,11 +27,6 @@ _.extend atom,
|
||||
setPackageState: (name, state) ->
|
||||
@packageStates[name] = state
|
||||
|
||||
serializeAtomPackages: ->
|
||||
for pack in @getActivePackages()
|
||||
@setPackageState(pack.name, state) if state = pack.serialize?()
|
||||
@packageStates
|
||||
|
||||
activatePackages: ->
|
||||
@activatePackage(pack.path) for pack in @getLoadedPackages()
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ class RootView extends View
|
||||
@div id: 'vertical', outlet: 'vertical', =>
|
||||
@subview 'panes', panes ? new PaneContainer
|
||||
|
||||
@deserialize: ({ panes, packages, projectPath }) ->
|
||||
atom.packageStates = packages ? {}
|
||||
@deserialize: ({ panes }) ->
|
||||
panes = deserialize(panes) if panes?.deserializer is 'PaneContainer'
|
||||
new RootView({panes})
|
||||
|
||||
@@ -73,7 +72,6 @@ class RootView extends View
|
||||
version: RootView.version
|
||||
deserializer: 'RootView'
|
||||
panes: @panes.serialize()
|
||||
packages: atom.serializeAtomPackages()
|
||||
|
||||
confirmClose: ->
|
||||
@panes.confirmClose()
|
||||
@@ -94,10 +92,6 @@ class RootView extends View
|
||||
afterAttach: (onDom) ->
|
||||
@focus() if onDom
|
||||
|
||||
deactivate: ->
|
||||
atom.deactivatePackages()
|
||||
@remove()
|
||||
|
||||
open: (path, options = {}) ->
|
||||
changeFocus = options.changeFocus ? true
|
||||
path = project.resolve(path) if path?
|
||||
|
||||
@@ -61,10 +61,12 @@ window.shutdown = ->
|
||||
return if not project and not rootView
|
||||
atom.setWindowState('pathToOpen', project.getPath())
|
||||
atom.setWindowState('project', project.serialize())
|
||||
atom.setWindowState('rootView', rootView.serialize())
|
||||
atom.setWindowState('syntax', syntax.serialize())
|
||||
atom.setWindowState('rootView', rootView.serialize())
|
||||
atom.deactivatePackages()
|
||||
atom.setWindowState('packageStates', atom.packageStates)
|
||||
rootView.remove()
|
||||
atom.saveWindowState()
|
||||
rootView.deactivate()
|
||||
project.destroy()
|
||||
git?.destroy()
|
||||
$(window).off('focus blur before')
|
||||
@@ -95,6 +97,7 @@ window.deserializeWindowState = ->
|
||||
|
||||
windowState = atom.getWindowState()
|
||||
|
||||
atom.packageStates = windowState.packageStates ? {}
|
||||
window.project = deserialize(windowState.project) ? new Project(pathToOpen)
|
||||
window.rootView = deserialize(windowState.rootView) ? new RootView
|
||||
|
||||
|
||||
Reference in New Issue
Block a user