diff --git a/spec/integration/startup-spec.coffee b/spec/integration/startup-spec.coffee index f6b0e1cf3..7c2503e69 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", -> + runAtom [tempDirPath], {ATOM_HOME: atomHome}, (client) -> + client + .waitForExist("atom-workspace") + .waitForNewWindow(-> + @startAnotherAtom([otherTempDirPath], ATOM_HOME: atomHome) + , 5000) + .waitForExist("atom-workspace") + + configPath = path.join(atomHome, 'config.cson') + config = CSON.readFileSync(configPath) + config['*'].core = {restorePreviousWindowsOnStart: false} + CSON.writeFileSync(configPath, config) + + 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 4767c9065..14713ee18 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -3,6 +3,7 @@ ApplicationMenu = require './application-menu' AtomProtocolHandler = require './atom-protocol-handler' AutoUpdateManager = require './auto-update-manager' StorageFolder = require '../storage-folder' +Config = require '../config' ipcHelpers = require '../ipc-helpers' {BrowserWindow, Menu, app, dialog, ipcMain, shell} = require 'electron' fs = require 'fs-plus' @@ -70,7 +71,11 @@ class AtomApplication @pidsToOpenWindows = {} @windows = [] - @autoUpdateManager = new AutoUpdateManager(@version, options.test, @resourcePath) + @config = new Config({configDirPath: process.env.ATOM_HOME, @resourcePath, enablePersistence: true}) + @config.setSchema null, {type: 'object', properties: _.clone(require('../config-schema'))} + @config.load() + + @autoUpdateManager = new AutoUpdateManager(@version, options.test, @resourcePath, @config) @applicationMenu = new ApplicationMenu(@version, @autoUpdateManager) @atomProtocolHandler = new AtomProtocolHandler(@resourcePath, @safeMode) @@ -510,7 +515,8 @@ class AtomApplication @storageFolder.storeSync('application.json', states) loadState: (options) -> - if (states = @storageFolder.load('application.json'))?.length > 0 + restorePreviousState = @config.get('core.restorePreviousWindowsOnStart') ? true + if restorePreviousState and (states = @storageFolder.load('application.json'))?.length > 0 for state in states @openWithOptions(_.extend(options, { initialPaths: state.initialPaths diff --git a/src/browser/auto-update-manager.coffee b/src/browser/auto-update-manager.coffee index c8c57cb01..8cf06b833 100644 --- a/src/browser/auto-update-manager.coffee +++ b/src/browser/auto-update-manager.coffee @@ -1,6 +1,5 @@ autoUpdater = null _ = require 'underscore-plus' -Config = require '../config' {EventEmitter} = require 'events' path = require 'path' @@ -16,13 +15,10 @@ module.exports = class AutoUpdateManager _.extend @prototype, EventEmitter.prototype - constructor: (@version, @testMode, resourcePath) -> + constructor: (@version, @testMode, resourcePath, @config) -> @state = IdleState @iconPath = path.resolve(__dirname, '..', '..', 'resources', 'atom.png') @feedUrl = "https://atom.io/api/updates?version=#{@version}" - @config = new Config({configDirPath: process.env.ATOM_HOME, resourcePath, enablePersistence: true}) - @config.setSchema null, {type: 'object', properties: _.clone(require('../config-schema'))} - @config.load() process.nextTick => @setupAutoUpdater() setupAutoUpdater: ->