Make an option to *always* restore the last session, no matter how Atom is invoked (#9643), part2: new option in Settings is merged with the old one, the result is a 3-value combobox [no, yes, always]

This commit is contained in:
Anatoli
2017-03-08 10:38:08 -03:00
parent b71a9bb010
commit 9e41a1b490
3 changed files with 8 additions and 12 deletions

View File

@@ -372,7 +372,7 @@ describe('AtomApplication', function () {
assert.deepEqual(await getTreeViewRootDirectories(app2Window2), [tempDirPath2])
})
it('does not reopen any previously opened windows when launched with no path and `core.restorePreviousWindowsOnStart` is false', async function () {
it('does not reopen any previously opened windows when launched with no path and `core.restorePreviousWindowsOnStart` is no', async function () {
const atomApplication1 = buildAtomApplication()
const app1Window1 = atomApplication1.launch(parseCommandLine([makeTempDir()]))
await focusWindow(app1Window1)
@@ -382,7 +382,7 @@ describe('AtomApplication', function () {
const configPath = path.join(process.env.ATOM_HOME, 'config.cson')
const config = season.readFileSync(configPath)
if (!config['*'].core) config['*'].core = {}
config['*'].core.restorePreviousWindowsOnStart = false
config['*'].core.restorePreviousWindowsOnStart = 'no'
season.writeFileSync(configPath, config)
const atomApplication2 = buildAtomApplication()

View File

@@ -258,14 +258,10 @@ const configSchema = {
default: true
},
restorePreviousWindowsOnStart: {
description: 'When checked restores the last state of all Atom windows when started from the icon or `atom` by itself from the command line; otherwise a blank environment is loaded.',
type: 'boolean',
default: true
},
restorePreviousWindowsOnStartAlways: {
description: 'When checked *ALWAYS* restores the last state of all Atom windows.',
type: 'boolean',
default: false
type: 'string',
enum: ['no', 'yes', 'always'],
default: 'yes',
description: "When selected 'no', a blank environment is loaded. When selected 'yes' and Atom is started from the icon or `atom` by itself from the command line, restores the last state of all Atom windows; otherwise a blank environment is loaded. When selected 'always', restores the last state of all Atom windows always, no matter how Atom is started."
},
reopenProjectMenuCount: {
description: 'How many recent projects to show in the Reopen Project menu.',

View File

@@ -111,7 +111,7 @@ class AtomApplication
launch: (options) ->
if options.pathsToOpen?.length > 0 or options.urlsToOpen?.length > 0 or options.test or options.benchmark or options.benchmarkTest
if @config.get('core.restorePreviousWindowsOnStartAlways')
if @config.get('core.restorePreviousWindowsOnStart') is 'always'
@loadState(clone(options))
@openWithOptions(options)
else
@@ -601,7 +601,7 @@ class AtomApplication
@storageFolder.storeSync('application.json', states)
loadState: (options) ->
if (@config.get('core.restorePreviousWindowsOnStartAlways') or @config.get('core.restorePreviousWindowsOnStart')) and (states = @storageFolder.load('application.json'))?.length > 0
if (@config.get('core.restorePreviousWindowsOnStart') in ['yes', 'always']) and (states = @storageFolder.load('application.json'))?.length > 0
for state in states
@openWithOptions(Object.assign(options, {
initialPaths: state.initialPaths