diff --git a/spec/integration/startup-spec.coffee b/spec/integration/startup-spec.coffee index f6b0e1cf3..136ca9676 100644 --- a/spec/integration/startup-spec.coffee +++ b/spec/integration/startup-spec.coffee @@ -268,6 +268,36 @@ describe "Starting Atom", -> [otherTempDirPath] ].sort() + it "doesn't reopen any previously opened windows if restorePreviousWindowsOnStart is disabled", -> + configPath = path.join(atomHome, 'config.cson') + config = CSON.readFileSync(configPath) + config['*'].core = {restorePreviousWindowsOnStart: false} + CSON.writeFileSync(configPath, config) + + runAtom [tempDirPath], {ATOM_HOME: atomHome}, (client) -> + client + .waitForExist("atom-workspace") + .waitForNewWindow(-> + @startAnotherAtom([otherTempDirPath], ATOM_HOME: atomHome) + , 5000) + .waitForExist("atom-workspace") + + runAtom [], {ATOM_HOME: atomHome}, (client) -> + windowProjectPaths = [] + + client + .waitForWindowCount(1, 10000) + .then ({value: windowHandles}) -> + @window(windowHandles[0]) + .waitForExist("atom-workspace") + .treeViewRootDirectories() + .then ({value: directories}) -> windowProjectPaths.push(directories) + + .call -> + expect(windowProjectPaths).toEqual [ + [] + ] + describe "opening a remote directory", -> it "opens the parent directory and creates an empty text editor", -> remoteDirectory = 'remote://server:3437/some/directory/path' diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index 416202cc6..d057aef52 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -506,12 +506,14 @@ class AtomApplication saveState: (allowEmpty=false) -> return if @quitting + restorePreviousState = @config.get('core.restorePreviousWindowsOnStart') ? true states = [] - for window in @windows - unless window.isSpec - if loadSettings = window.getLoadSettings() - states.push(initialPaths: loadSettings.initialPaths) - if states.length > 0 or allowEmpty + if restorePreviousState + for window in @windows + unless window.isSpec + if loadSettings = window.getLoadSettings() + states.push(initialPaths: loadSettings.initialPaths) + if states.length > 0 or allowEmpty or not restorePreviousState @storageFolder.storeSync('application.json', states) loadState: (options) ->