From b71a9bb010b98befc1e1bfbb832ea29dd6181c74 Mon Sep 17 00:00:00 2001 From: Anatoli Date: Tue, 7 Mar 2017 04:56:10 -0300 Subject: [PATCH 1/9] Make an option to *always* restore the last session, no matter how Atom is invoked (#9643) --- src/config-schema.js | 5 +++++ src/main-process/atom-application.coffee | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/config-schema.js b/src/config-schema.js index 41b5ecbb6..1d41aeb9d 100644 --- a/src/config-schema.js +++ b/src/config-schema.js @@ -262,6 +262,11 @@ const configSchema = { type: 'boolean', default: true }, + restorePreviousWindowsOnStartAlways: { + description: 'When checked *ALWAYS* restores the last state of all Atom windows.', + type: 'boolean', + default: false + }, reopenProjectMenuCount: { description: 'How many recent projects to show in the Reopen Project menu.', type: 'integer', diff --git a/src/main-process/atom-application.coffee b/src/main-process/atom-application.coffee index 93e9e3395..27f337cfe 100644 --- a/src/main-process/atom-application.coffee +++ b/src/main-process/atom-application.coffee @@ -111,6 +111,8 @@ 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') + @loadState(clone(options)) @openWithOptions(options) else @loadState(options) or @openPath(options) @@ -558,6 +560,7 @@ class AtomApplication windowDimensions ?= @getDimensionsForNewWindow() openedWindow = new AtomWindow(this, @fileRecoveryService, {initialPaths, locationsToOpen, windowInitializationScript, resourcePath, devMode, safeMode, windowDimensions, profileStartup, clearWindowState, env}) openedWindow.focus() + @lastFocusedWindow = openedWindow if pidToKillWhenClosed? @pidsToOpenWindows[pidToKillWhenClosed] = openedWindow @@ -598,8 +601,7 @@ class AtomApplication @storageFolder.storeSync('application.json', states) loadState: (options) -> - restorePreviousState = @config.get('core.restorePreviousWindowsOnStart') ? true - if restorePreviousState and (states = @storageFolder.load('application.json'))?.length > 0 + if (@config.get('core.restorePreviousWindowsOnStartAlways') or @config.get('core.restorePreviousWindowsOnStart')) and (states = @storageFolder.load('application.json'))?.length > 0 for state in states @openWithOptions(Object.assign(options, { initialPaths: state.initialPaths @@ -812,3 +814,10 @@ class AtomApplication args.push("--resource-path=#{@resourcePath}") app.relaunch({args}) app.quit() + + clone = (obj) -> + return obj if obj is null or typeof (obj) isnt "object" + temp = new obj.constructor() + for key of obj + temp[key] = clone(obj[key]) + temp From 9e41a1b490ace7ee6ec4fcd55f33639e063a24d0 Mon Sep 17 00:00:00 2001 From: Anatoli Date: Wed, 8 Mar 2017 10:38:08 -0300 Subject: [PATCH 2/9] 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] --- spec/main-process/atom-application.test.js | 4 ++-- src/config-schema.js | 12 ++++-------- src/main-process/atom-application.coffee | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/spec/main-process/atom-application.test.js b/spec/main-process/atom-application.test.js index d30900b99..a901a2609 100644 --- a/spec/main-process/atom-application.test.js +++ b/spec/main-process/atom-application.test.js @@ -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() diff --git a/src/config-schema.js b/src/config-schema.js index 1d41aeb9d..8aee7f215 100644 --- a/src/config-schema.js +++ b/src/config-schema.js @@ -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.', diff --git a/src/main-process/atom-application.coffee b/src/main-process/atom-application.coffee index 27f337cfe..d0595ba32 100644 --- a/src/main-process/atom-application.coffee +++ b/src/main-process/atom-application.coffee @@ -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 From 6cc90c46ed5212cfe5bbbaa2c05f35989aef9aed Mon Sep 17 00:00:00 2001 From: Anatoli Date: Wed, 8 Mar 2017 17:37:22 -0300 Subject: [PATCH 3/9] Make an option to *always* restore the last session, no matter how Atom is invoked (#9643), part3: use _.cloneDeep from lodash instead of own clone function --- src/main-process/atom-application.coffee | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main-process/atom-application.coffee b/src/main-process/atom-application.coffee index d0595ba32..382caef6c 100644 --- a/src/main-process/atom-application.coffee +++ b/src/main-process/atom-application.coffee @@ -112,7 +112,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.restorePreviousWindowsOnStart') is 'always' - @loadState(clone(options)) + @loadState(_.cloneDeep(options)) @openWithOptions(options) else @loadState(options) or @openPath(options) @@ -814,10 +814,3 @@ class AtomApplication args.push("--resource-path=#{@resourcePath}") app.relaunch({args}) app.quit() - - clone = (obj) -> - return obj if obj is null or typeof (obj) isnt "object" - temp = new obj.constructor() - for key of obj - temp[key] = clone(obj[key]) - temp From 07c0498cf147242f215fa509f22a69caf47edc51 Mon Sep 17 00:00:00 2001 From: Anatoli Date: Fri, 10 Mar 2017 06:13:05 -0300 Subject: [PATCH 4/9] Make an option to *always* restore the last session, no matter how Atom is invoked (#9643), part4: import cloneDeep directly from lodash --- package.json | 1 + src/main-process/atom-application.coffee | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ed3756a38..a5b5a5f2e 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "key-path-helpers": "^0.4.0", "less-cache": "0.23", "line-top-index": "0.2.0", + "lodash.clonedeep": "*", "marked": "^0.3.6", "minimatch": "^3.0.3", "mocha": "2.5.1", diff --git a/src/main-process/atom-application.coffee b/src/main-process/atom-application.coffee index 382caef6c..c1c7168ae 100644 --- a/src/main-process/atom-application.coffee +++ b/src/main-process/atom-application.coffee @@ -15,6 +15,7 @@ net = require 'net' url = require 'url' {EventEmitter} = require 'events' _ = require 'underscore-plus' +cloneDeep = require 'lodash.clonedeep' FindParentDir = null Resolve = null @@ -112,7 +113,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.restorePreviousWindowsOnStart') is 'always' - @loadState(_.cloneDeep(options)) + @loadState(cloneDeep(options)) @openWithOptions(options) else @loadState(options) or @openPath(options) From a6e60762becccfc8ed6db2903cdc984c6b0b831c Mon Sep 17 00:00:00 2001 From: Anatoli Date: Fri, 10 Mar 2017 17:20:35 -0300 Subject: [PATCH 5/9] Make an option to *always* restore the last session, no matter how Atom is invoked (#9643), part5: use _.deepClone from underscore-plus --- package.json | 1 - src/main-process/atom-application.coffee | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index a5b5a5f2e..ed3756a38 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,6 @@ "key-path-helpers": "^0.4.0", "less-cache": "0.23", "line-top-index": "0.2.0", - "lodash.clonedeep": "*", "marked": "^0.3.6", "minimatch": "^3.0.3", "mocha": "2.5.1", diff --git a/src/main-process/atom-application.coffee b/src/main-process/atom-application.coffee index c1c7168ae..02a5e68de 100644 --- a/src/main-process/atom-application.coffee +++ b/src/main-process/atom-application.coffee @@ -15,7 +15,6 @@ net = require 'net' url = require 'url' {EventEmitter} = require 'events' _ = require 'underscore-plus' -cloneDeep = require 'lodash.clonedeep' FindParentDir = null Resolve = null @@ -113,7 +112,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.restorePreviousWindowsOnStart') is 'always' - @loadState(cloneDeep(options)) + @loadState(_.deepClone(options)) @openWithOptions(options) else @loadState(options) or @openPath(options) From 5d57ecb8ce2075465e8dafbf34c7e79c3de8cd5b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 8 May 2017 16:05:17 -0600 Subject: [PATCH 6/9] :arrow_up: text-buffer --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31117726f..f193f350d 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "sinon": "1.17.4", "source-map-support": "^0.3.2", "temp": "^0.8.3", - "text-buffer": "11.4.1", + "text-buffer": "12.1.1", "typescript-simple": "1.0.0", "underscore-plus": "^1.6.6", "winreg": "^1.2.1", From afd74be7363014cbb6cab4cc92c53e742200888d Mon Sep 17 00:00:00 2001 From: Lee Dohm Date: Tue, 9 May 2017 10:10:24 -0700 Subject: [PATCH 7/9] Add configuration for probot-stale --- .github/stale.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 000000000..968743bd9 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,24 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +# Starting at two years of no activity +daysUntilStale: 730 +# Number of days of inactivity before a stale Issue or Pull Request is closed +daysUntilClose: 30 +# Issues or Pull Requests with these labels will never be considered stale +exemptLabels: + - security + - triaged +# Label to use when marking as stale +staleLabel: stale +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when removing the stale label. Set to `false` to disable +unmarkComment: false +# Comment to post when closing a stale Issue or Pull Request. Set to `false` to disable +closeComment: false +# Limit to only `issues` or `pulls` +only: issues From 36a25bfc537f1471ec83d595d0d72f7a86448350 Mon Sep 17 00:00:00 2001 From: Lee Dohm Date: Tue, 9 May 2017 10:17:49 -0700 Subject: [PATCH 8/9] Add regression label to list of exemptions --- .github/stale.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/stale.yml b/.github/stale.yml index 968743bd9..c96fb719e 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -7,6 +7,7 @@ daysUntilStale: 730 daysUntilClose: 30 # Issues or Pull Requests with these labels will never be considered stale exemptLabels: + - regression - security - triaged # Label to use when marking as stale From ea8524ec1b53e89b76de3278d0b10a7a9d44618e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 10 May 2017 11:37:12 -0600 Subject: [PATCH 9/9] Revert ":arrow_up: text-buffer" This reverts commit 5d57ecb8ce2075465e8dafbf34c7e79c3de8cd5b. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f193f350d..31117726f 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "sinon": "1.17.4", "source-map-support": "^0.3.2", "temp": "^0.8.3", - "text-buffer": "12.1.1", + "text-buffer": "11.4.1", "typescript-simple": "1.0.0", "underscore-plus": "^1.6.6", "winreg": "^1.2.1",