atom project open in their own windows and behave more sanely

This commit is contained in:
Philip Weiss
2018-02-23 17:38:36 -08:00
parent ad40ff9825
commit e2c480847c
4 changed files with 22 additions and 11 deletions

View File

@@ -202,6 +202,7 @@ class AtomApplication extends EventEmitter {
openWithOptions (options) {
const {
projectSettings,
initialPaths,
pathsToOpen,
executedFrom,
@@ -256,6 +257,7 @@ class AtomApplication extends EventEmitter {
profileStartup,
clearWindowState,
addToLastWindow,
projectSettings,
env
})
} else if (urlsToOpen.length > 0) {
@@ -819,6 +821,7 @@ class AtomApplication extends EventEmitter {
window,
clearWindowState,
addToLastWindow,
projectSettings,
env
} = {}) {
if (!pathsToOpen || pathsToOpen.length === 0) return
@@ -853,7 +856,7 @@ class AtomApplication extends EventEmitter {
}
let openedWindow
if (existingWindow) {
if (existingWindow && projectSettings == null) {
openedWindow = existingWindow
openedWindow.openLocations(locationsToOpen)
if (openedWindow.isMinimized()) {
@@ -878,6 +881,7 @@ class AtomApplication extends EventEmitter {
}
if (!resourcePath) resourcePath = this.resourcePath
if (!windowDimensions) windowDimensions = this.getDimensionsForNewWindow()
openedWindow = new AtomWindow(this, this.fileRecoveryService, {
initialPaths,
locationsToOpen,
@@ -888,6 +892,7 @@ class AtomApplication extends EventEmitter {
windowDimensions,
profileStartup,
clearWindowState,
projectSettings,
env
})
this.addWindow(openedWindow)

View File

@@ -22,6 +22,7 @@ class AtomWindow extends EventEmitter {
this.safeMode = settings.safeMode
this.devMode = settings.devMode
this.resourcePath = settings.resourcePath
this.projectSettings = settings.projectSettings
let {pathToOpen, locationsToOpen} = settings
if (!locationsToOpen && pathToOpen) locationsToOpen = [{pathToOpen}]
@@ -55,18 +56,12 @@ class AtomWindow extends EventEmitter {
if (this.shouldHideTitleBar()) options.frame = false
this.browserWindow = new BrowserWindow(options)
let projectSettings
if (this.atomApplication.projectSettings != null) {
projectSettings = this.atomApplication.projectSettings
this.projectSettings = this.atomApplication.projectSettings
}
Object.defineProperty(this.browserWindow, 'loadSettingsJSON', {
get: () => JSON.stringify(Object.assign({
userSettings: this.atomApplication.configFile.get(),
projectSettings
}, this.loadSettings)),
configurable: true
})
this.loadDataOverProcessBoundary()
this.handleEvents()
@@ -159,6 +154,16 @@ class AtomWindow extends EventEmitter {
return paths.every(p => this.containsPath(p))
}
loadDataOverProcessBoundary() {
Object.defineProperty(this.browserWindow, 'loadSettingsJSON', {
get: () => JSON.stringify(Object.assign({
userSettings: this.atomApplication.configFile.get(),
projectSettings: this.getProjectSettings()
}, this.loadSettings)),
configurable: true
})
}
containsPath (pathToCheck) {
if (!pathToCheck) return false
const stat = fs.statSyncNoException(pathToCheck)