diff --git a/src/atom-environment.js b/src/atom-environment.js index 52780e648..45fcb3bbd 100644 --- a/src/atom-environment.js +++ b/src/atom-environment.js @@ -223,8 +223,8 @@ class AtomEnvironment { }) this.config.resetUserSettings(userSettings) - if (projectSettings != null) { - this.project.resetProjectSettings(projectSettings) + if (projectSettings != null && projectSettings.paths != null || projectSettings.config != null) { + this.project.replaceAtomProject(projectSettings) } this.menu.initialize({resourcePath}) diff --git a/src/config.js b/src/config.js index 5922da368..8c7fd85b7 100644 --- a/src/config.js +++ b/src/config.js @@ -1013,6 +1013,7 @@ class Config { resetProjectSettings (newSettings, options = {}) { // Sets the scope and source of all project settings to `path`. + newSettings = Object.assign({}, newSettings) this.hasCurrentProject = !options.removeProject const pathScopedSettings = {} pathScopedSettings[PROJECT] = newSettings diff --git a/src/main-process/atom-application.js b/src/main-process/atom-application.js index b198b722a..38316497a 100644 --- a/src/main-process/atom-application.js +++ b/src/main-process/atom-application.js @@ -856,7 +856,7 @@ class AtomApplication extends EventEmitter { } let openedWindow - if (existingWindow && projectSettings == null) { + if (existingWindow && projectSettings.paths == null && projectSettings.config == null) { openedWindow = existingWindow openedWindow.openLocations(locationsToOpen) if (openedWindow.isMinimized()) { diff --git a/src/main-process/atom-window.js b/src/main-process/atom-window.js index 3f8b7a1af..bd93c9cc4 100644 --- a/src/main-process/atom-window.js +++ b/src/main-process/atom-window.js @@ -158,7 +158,7 @@ class AtomWindow extends EventEmitter { Object.defineProperty(this.browserWindow, 'loadSettingsJSON', { get: () => JSON.stringify(Object.assign({ userSettings: this.atomApplication.configFile.get(), - projectSettings: this.getProjectSettings() + projectSettings: this.projectSettings }, this.loadSettings)), configurable: true }) diff --git a/src/main-process/parse-command-line.js b/src/main-process/parse-command-line.js index 73160ae1c..98b89bb73 100644 --- a/src/main-process/parse-command-line.js +++ b/src/main-process/parse-command-line.js @@ -138,14 +138,17 @@ module.exports = function parseCommandLine (processArgs) { devMode = true } - let projectSettings + let projectSettings = {} if (atomProject) { - const config = readProjectSettingsSync(atomProject, executedFrom) - const paths = config.paths - projectSettings = config.config + const contents = readProjectSettingsSync(atomProject, executedFrom) + const paths = contents.paths + const config = contents.config + const originPath = atomProject if (paths != null) { pathsToOpen = pathsToOpen.concat(paths) } + projectSettings = { originPath, paths, config } + } if (devMode) { @@ -198,7 +201,7 @@ const readProjectSettingsSync = (filepath, executedFrom) => { try { const readPath = path.isAbsolute(filepath) ? filepath : path.join(executedFrom, filepath) const contents = CSON.readFileSync(readPath) - if (contents.paths || content.config) { + if (contents.paths || contents.config) { return contents } diff --git a/src/project.js b/src/project.js index 7a5680da0..e660c7e31 100644 --- a/src/project.js +++ b/src/project.js @@ -38,6 +38,7 @@ class Project extends Model { this.retiredBufferIDs = new Set() this.retiredBufferPaths = new Set() this.subscriptions = new CompositeDisposable() + this.projectFilePath = null this.consumeServices(packageManager) } @@ -77,14 +78,21 @@ class Project extends Model { } } - resetProjectSettings (newSettings) { - atom.config.resetProjectSettings(newSettings) + // Layers the contents of an atomProject file's config + // on top of the current global config. + replaceAtomProject (newSettings) { + atom.config.resetProjectSettings(newSettings.config) + this.projectFilePath = newSettings.originPath } clearProjectSettings () { atom.config.clearProjectSettings() } + getProjectFilePath () { + return this.projectFilePath + } + /* Section: Serialization */