diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index d37eeb7a8..4690e981a 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -39,6 +39,7 @@ beforeEach -> atom.atomPackageStates = {} atom.loadedPackages = [] spyOn(atom, 'saveWindowState') + spyOn(atom, 'getSavedWindowState').andReturn(null) $native.setWindowState('') # used to reset keymap after each spec diff --git a/src/app/atom.coffee b/src/app/atom.coffee index 7957db51d..604c15821 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -198,14 +198,22 @@ _.extend atom, windowState getWindowState: (keyPath) -> - inMemoryState = $native.getWindowState() - inMemoryState = null unless inMemoryState.length > 0 - windowState = JSON.parse(inMemoryState ? localStorage[window.location.params.pathToOpen] ? '{}') + windowState = JSON.parse(@getInMemoryWindowState() ? @getSavedWindowState() ? '{}') if keyPath _.valueForKeyPath(windowState, keyPath) else windowState + getInMemoryWindowState: -> + inMemoryState = $native.getWindowState() + if inMemoryState.length > 0 + inMemoryState + else + null + + getSavedWindowState: -> + localStorage[window.location.params.pathToOpen] + saveWindowState: -> localStorage[@getPathToOpen()] = JSON.stringify(@getWindowState())