Update AtomWindow::projectRoots synchronously on openLocations()

This commit is contained in:
Ash Wilson
2019-04-24 15:04:59 -04:00
parent f1e0843473
commit a53addbf78
2 changed files with 33 additions and 4 deletions

View File

@@ -72,10 +72,7 @@ class AtomWindow extends EventEmitter {
if (this.loadSettings.safeMode == null) this.loadSettings.safeMode = false
if (this.loadSettings.clearWindowState == null) this.loadSettings.clearWindowState = false
this.projectRoots = locationsToOpen
.filter(location => location.pathToOpen && location.exists && location.isDirectory)
.map(location => location.pathToOpen)
this.projectRoots.sort()
this.addLocationsToOpen(locationsToOpen)
this.loadSettings.hasOpenFiles = locationsToOpen
.some(location => location.pathToOpen && !location.isDirectory)
@@ -240,6 +237,7 @@ class AtomWindow extends EventEmitter {
}
async openLocations (locationsToOpen) {
this.addLocationsToOpen(locationsToOpen)
await this.loadedPromise
this.sendMessage('open-locations', locationsToOpen)
}
@@ -252,6 +250,18 @@ class AtomWindow extends EventEmitter {
this.sendMessage('did-fail-to-read-user-settings', message)
}
addLocationsToOpen (locationsToOpen) {
const roots = new Set(this.projectRoots || [])
for (const {pathToOpen, isDirectory} of locationsToOpen) {
if (isDirectory) {
roots.add(pathToOpen)
}
}
this.projectRoots = Array.from(roots)
this.projectRoots.sort()
}
replaceEnvironment (env) {
this.browserWindow.webContents.send('environment', env)
}