mirror of
https://github.com/atom/atom.git
synced 2026-01-26 07:19:06 -05:00
Don't serialize packages in deactivatePackages
Serialization still occurs when deactivating a single package via the API. Otherwise, when the window is closed or reloaded we will serialize all packages as a result of saving the window state. Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
This commit is contained in:
committed by
Max Brunsfeld
parent
3a4ae04f74
commit
b7126aff4c
@@ -502,6 +502,7 @@ describe "PackageManager", ->
|
||||
runs ->
|
||||
expect(pack.mainModule.someNumber).not.toBe 77
|
||||
pack.mainModule.someNumber = 77
|
||||
atom.packages.serializePackage("package-with-serialization")
|
||||
atom.packages.deactivatePackage("package-with-serialization")
|
||||
spyOn(pack.mainModule, 'activate').andCallThrough()
|
||||
waitsForPromise ->
|
||||
@@ -899,6 +900,22 @@ describe "PackageManager", ->
|
||||
expect(atom.packages.packageStates['package-with-serialization']).toEqual someNumber: 1
|
||||
expect(console.error).toHaveBeenCalled()
|
||||
|
||||
describe "::deactivatePackages()", ->
|
||||
it "deactivates all packages but does not serialize them", ->
|
||||
[pack1, pack2] = []
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage("package-with-deactivate").then (p) -> pack1 = p
|
||||
atom.packages.activatePackage("package-with-serialization").then (p) -> pack2 = p
|
||||
|
||||
runs ->
|
||||
spyOn(pack1.mainModule, 'deactivate')
|
||||
spyOn(pack2.mainModule, 'serialize')
|
||||
atom.packages.deactivatePackages()
|
||||
|
||||
expect(pack1.mainModule.deactivate).toHaveBeenCalled()
|
||||
expect(pack2.mainModule.serialize).not.toHaveBeenCalled()
|
||||
|
||||
describe "::deactivatePackage(id)", ->
|
||||
afterEach ->
|
||||
atom.packages.unloadPackages()
|
||||
|
||||
@@ -486,15 +486,15 @@ class PackageManager
|
||||
# Deactivate all packages
|
||||
deactivatePackages: ->
|
||||
@config.transact =>
|
||||
@deactivatePackage(pack.name) for pack in @getLoadedPackages()
|
||||
@deactivatePackage(pack.name, true) for pack in @getLoadedPackages()
|
||||
return
|
||||
@unobserveDisabledPackages()
|
||||
@unobservePackagesWithKeymapsDisabled()
|
||||
|
||||
# Deactivate the package with the given name
|
||||
deactivatePackage: (name) ->
|
||||
deactivatePackage: (name, suppressSerialization) ->
|
||||
pack = @getLoadedPackage(name)
|
||||
@serializePackage(pack) if @isPackageActive(pack.name)
|
||||
@serializePackage(pack) if not suppressSerialization and @isPackageActive(pack.name)
|
||||
pack.deactivate()
|
||||
delete @activePackages[pack.name]
|
||||
delete @activatingPackages[pack.name]
|
||||
|
||||
Reference in New Issue
Block a user