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