diff --git a/spec/app/window-spec.coffee b/spec/app/window-spec.coffee index 825eefb4c..ff82cc5fa 100644 --- a/spec/app/window-spec.coffee +++ b/spec/app/window-spec.coffee @@ -109,3 +109,9 @@ describe "Window", -> shutdown() expect(editor1.getBuffer().subscriptionCount()).toBe 0 + + it "only serializes window state the first time it is called", -> + deactivateSpy = spyOn(atom, "setRootViewStateForPath").andCallThrough() + window.shutdown() + window.shutdown() + expect(atom.setRootViewStateForPath.callCount).toBe 1 diff --git a/src/app/window.coffee b/src/app/window.coffee index 59135f8e2..b181d4f0a 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -8,6 +8,7 @@ require 'underscore-extensions' require 'space-pen-extensions' deserializers = {} +wasShutdown = false windowAdditions = rootViewParentSelector: 'body' @@ -68,6 +69,8 @@ windowAdditions = $(rootViewParentSelector).append(rootView) shutdown: -> + return if wasShutdown + wasShutdown = true atom.setWindowState('pathToOpen', project.getPath()) atom.setRootViewStateForPath project.getPath(), project: project.serialize()