mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Merge pull request #6979 from atom/mb-save-window-state-even-more
Save window state when quitting if windows are open
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user