From bcfa4ef6082eaf597278fff3386ecaab6ce8bfac Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 17 Feb 2015 15:25:50 -0800 Subject: [PATCH] Restore old behavior for multiple path CLI args Signed-off-by: Nathan Sobo --- spec/integration/startup-spec.coffee | 23 ++++++++++++++++++++++- src/browser/atom-application.coffee | 8 ++++++-- src/browser/atom-window.coffee | 1 + src/browser/main.coffee | 5 ++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/spec/integration/startup-spec.coffee b/spec/integration/startup-spec.coffee index 4cc5b1525..ae0001814 100644 --- a/spec/integration/startup-spec.coffee +++ b/spec/integration/startup-spec.coffee @@ -86,7 +86,7 @@ describe "Starting Atom", -> .waitForPaneItemCount(1, 5000) it "allows multiple project directories to be passed as separate arguments", -> - runAtom [tempDirPath, otherTempDirPath], {ATOM_HOME: AtomHome}, (client) -> + runAtom [tempDirPath, otherTempDirPath, "--multi-folder"], {ATOM_HOME: AtomHome}, (client) -> client .waitForExist("atom-workspace", 5000) .then((exists) -> expect(exists).toBe true) @@ -100,3 +100,24 @@ describe "Starting Atom", -> .waitForPaneItemCount(1, 5000) .execute(-> atom.project.getPaths()) .then(({value}) -> expect(value).toEqual([tempDirPath, otherTempDirPath])) + + it "opens each path in its own window unless the --multi-folder flag is passed", -> + runAtom [tempDirPath, otherTempDirPath], {ATOM_HOME: AtomHome}, (client) -> + projectPaths = [] + + client + .waitForWindowCount(2, 5000) + .windowHandles() + .then ({value: windowHandles}) -> + @window(windowHandles[0]) + .execute(-> atom.project.getPaths()) + .then ({value}) -> + expect(value).toHaveLength(1) + projectPaths.push(value[0]) + .window(windowHandles[1]) + .execute(-> atom.project.getPaths()) + .then ({value}) -> + expect(value).toHaveLength(1) + projectPaths.push(value[0]) + .then -> + expect(projectPaths.sort()).toEqual([tempDirPath, otherTempDirPath].sort()) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index 4cc25f551..44e43bdd7 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -82,11 +82,15 @@ class AtomApplication @openWithOptions(options) # Opens a new window based on the options provided. - openWithOptions: ({pathsToOpen, urlsToOpen, test, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory, logFile}) -> + openWithOptions: ({pathsToOpen, urlsToOpen, test, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory, logFile, enableMultiFolderProject}) -> if test @runSpecs({exitWhenDone: true, @resourcePath, specDirectory, logFile}) else if pathsToOpen.length > 0 - @openPaths({pathsToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode}) + if enableMultiFolderProject + @openPaths({pathsToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode}) + else + for pathToOpen in pathsToOpen + @openPath({pathToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode}) else if urlsToOpen.length > 0 @openUrl({urlToOpen, devMode, safeMode}) for urlToOpen in urlsToOpen else diff --git a/src/browser/atom-window.coffee b/src/browser/atom-window.coffee index bf43b0241..19c74d943 100644 --- a/src/browser/atom-window.coffee +++ b/src/browser/atom-window.coffee @@ -58,6 +58,7 @@ class AtomWindow else pathToOpen loadSettings.initialPaths.sort() + @projectPaths = loadSettings.initialPaths @browserWindow.loadSettings = loadSettings @browserWindow.once 'window:loaded', => diff --git a/src/browser/main.coffee b/src/browser/main.coffee index 3b6018d5b..b73556307 100644 --- a/src/browser/main.coffee +++ b/src/browser/main.coffee @@ -118,6 +118,7 @@ parseCommandLine = -> options.alias('v', 'version').boolean('v').describe('v', 'Print the version.') options.alias('w', 'wait').boolean('w').describe('w', 'Wait for window to be closed before returning.') options.string('socket-path') + options.boolean('multi-folder') args = options.argv if args.help @@ -139,6 +140,7 @@ parseCommandLine = -> pidToKillWhenClosed = args['pid'] if args['wait'] logFile = args['log-file'] socketPath = args['socket-path'] + enableMultiFolderProject = args['multi-folder'] if args['resource-path'] devMode = true @@ -163,6 +165,7 @@ parseCommandLine = -> # explicitly pass it by command line, see http://git.io/YC8_Ew. process.env.PATH = args['path-environment'] if args['path-environment'] - {resourcePath, pathsToOpen, executedFrom, test, version, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory, logFile, socketPath} + {resourcePath, pathsToOpen, executedFrom, test, version, pidToKillWhenClosed, + devMode, safeMode, newWindow, specDirectory, logFile, socketPath, enableMultiFolderProject} start()