From b7b5ceca2ddeac1721ba906bd7ae289d6e6ef3ef Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 27 May 2015 12:59:06 -0700 Subject: [PATCH] Save window state when quitting if windows are open --- src/browser/atom-application.coffee | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index 1b2aa2e86..ae56fb1d4 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -99,12 +99,12 @@ class AtomApplication # Public: Removes the {AtomWindow} from the global window list. removeWindow: (window) -> - @windows.splice @windows.indexOf(window), 1 - if @windows.length is 0 + if @windows.length is 1 @applicationMenu?.enableWindowSpecificItems(false) if process.platform in ['win32', 'linux'] app.quit() return + @windows.splice(@windows.indexOf(window), 1) @saveState() unless window.isSpec or @quitting # Public: Adds the {AtomWindow} to the global window list. @@ -210,6 +210,7 @@ class AtomApplication @openPathOnEvent('application:open-license', path.join(process.resourcesPath, 'LICENSE.md')) app.on 'before-quit', => + @saveState() if @hasEditorWindows() @quitting = true app.on 'will-quit', => @@ -217,7 +218,7 @@ class AtomApplication @deleteSocketFile() app.on 'will-exit', => - @saveState() unless @windows.every (window) -> window.isSpec + @saveState() if @hasEditorWindows() @killAllProcesses() @deleteSocketFile() @@ -435,6 +436,9 @@ class AtomApplication states.push(initialPaths: loadSettings.initialPaths) @storageFolder.store('application.json', states) + hasEditorWindows: -> + @windows.some (window) -> not window.isSpec + loadState: -> if (states = @storageFolder.load('application.json'))?.length > 0 for state in states