From 952c42c0de8cdab2661856f5dd4789a1d69e08ee Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Thu, 18 Apr 2019 16:14:36 -0400 Subject: [PATCH] Rename initialPaths and representedDirectoryPaths They're now called initialProjectRoots and projectRoots, which is closer to what they actually are. --- src/atom-environment.js | 6 +++--- src/main-process/atom-application.js | 2 +- src/main-process/atom-window.js | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/atom-environment.js b/src/atom-environment.js index 98a89fe45..71a700ede 100644 --- a/src/atom-environment.js +++ b/src/atom-environment.js @@ -916,8 +916,8 @@ class AtomEnvironment { openInitialEmptyEditorIfNecessary () { if (!this.config.get('core.openEmptyEditorOnStart')) return - const {initialPaths} = this.getLoadSettings() - if (initialPaths && initialPaths.length === 0 && this.workspace.getPaneItems().length === 0) { + const {initialProjectRoots} = this.getLoadSettings() + if (initialProjectRoots && initialProjectRoots.length === 0 && this.workspace.getPaneItems().length === 0) { return this.workspace.open(null) } } @@ -1213,7 +1213,7 @@ or use Pane::saveItemAs for programmatic saving.`) loadState (stateKey) { if (this.enablePersistence) { - if (!stateKey) stateKey = this.getStateKey(this.getLoadSettings().initialPaths) + if (!stateKey) stateKey = this.getStateKey(this.getLoadSettings().initialProjectRoots) if (stateKey) { return this.stateStore.load(stateKey) } else { diff --git a/src/main-process/atom-application.js b/src/main-process/atom-application.js index 5b986bf10..7f623aa90 100644 --- a/src/main-process/atom-application.js +++ b/src/main-process/atom-application.js @@ -1115,7 +1115,7 @@ class AtomApplication extends EventEmitter { const states = [] for (let window of this.getAllWindows()) { - if (!window.isSpec) states.push({initialPaths: window.representedDirectoryPaths}) + if (!window.isSpec) states.push({initialPaths: window.initialProjectRoots}) } states.reverse() diff --git a/src/main-process/atom-window.js b/src/main-process/atom-window.js index db936a590..e2f2591f4 100644 --- a/src/main-process/atom-window.js +++ b/src/main-process/atom-window.js @@ -70,8 +70,12 @@ class AtomWindow extends EventEmitter { if (this.loadSettings.safeMode == null) this.loadSettings.safeMode = false if (this.loadSettings.clearWindowState == null) this.loadSettings.clearWindowState = false - this.loadSettings.initialPaths = locationsToOpen.map(location => location.pathToOpen).filter(Boolean) - this.loadSettings.initialPaths.sort() + this.projectRoots = locationsToOpen + .filter(location => location.pathToOpen && location.exists && location.isDirectory) + .map(location => location.pathToOpen) + this.projectRoots.sort() + + this.loadSettings.initialProjectRoots = this.projectRoots // Only send to the first non-spec window created if (includeShellLoadTime && !this.isSpec) { @@ -81,7 +85,6 @@ class AtomWindow extends EventEmitter { } } - this.representedDirectoryPaths = this.loadSettings.initialPaths if (!this.loadSettings.env) this.env = this.loadSettings.env this.browserWindow.on('window:loaded', () => { @@ -119,7 +122,7 @@ class AtomWindow extends EventEmitter { } hasProjectPath () { - return this.representedDirectoryPaths.length > 0 + return this.projectRoots.length > 0 } setupContextMenu () { @@ -377,7 +380,7 @@ class AtomWindow extends EventEmitter { showSaveDialog (options, callback) { options = Object.assign({ title: 'Save File', - defaultPath: this.representedDirectoryPaths[0] + defaultPath: this.projectRoots[0] }, options) if (typeof callback === 'function') { @@ -410,9 +413,9 @@ class AtomWindow extends EventEmitter { } setRepresentedDirectoryPaths (representedDirectoryPaths) { - this.representedDirectoryPaths = representedDirectoryPaths - this.representedDirectoryPaths.sort() - this.loadSettings.initialPaths = this.representedDirectoryPaths + this.projectRoots = projectRootPaths + this.projectRoots.sort() + this.loadSettings.initialProjectRoots = this.projectRoots return this.atomApplication.saveCurrentWindowOptions() }