Only load/save AtomEnvironment state if persistence is enabled

This commit is contained in:
Nathan Sobo
2015-10-14 22:10:51 -06:00
parent dc44d11a2c
commit b58b3504f4
3 changed files with 10 additions and 5 deletions

View File

@@ -141,10 +141,13 @@ describe "AtomEnvironment", ->
expect(errors).toEqual []
describe "saving and loading", ->
it "selects the state based on the current project paths", ->
jasmine.unspy(atom, 'saveStateSync')
# jasmine.unspy(atom, 'loadStateSync')
beforeEach ->
atom.enablePersistence = true
afterEach ->
atom.enablePersistence = false
it "selects the state based on the current project paths", ->
[dir1, dir2] = [temp.mkdirSync("dir1-"), temp.mkdirSync("dir2-")]
loadSettings = _.extend atom.getLoadSettings(),

View File

@@ -74,8 +74,6 @@ beforeEach ->
spyOn(window, "setTimeout").andCallFake window.fakeSetTimeout
spyOn(window, "clearTimeout").andCallFake window.fakeClearTimeout
spyOn(atom, 'saveStateSync')
spy = spyOn(atom.packages, 'resolvePackagePath').andCallFake (packageName) ->
if specPackageName and packageName is specPackageName
resolvePackagePath(specPackagePath)

View File

@@ -758,12 +758,16 @@ class AtomEnvironment extends Model
@applicationDelegate.showSaveDialog(options)
saveStateSync: ->
return unless @enablePersistence
if storageKey = @getStateKey(@project?.getPaths())
@getStorageFolder().store(storageKey, @state)
else
@getCurrentWindow().loadSettings.windowState = JSON.stringify(@state)
loadStateSync: ->
return unless @enablePersistence
startTime = Date.now()
if stateKey = @getStateKey(@getLoadSettings().initialPaths)