From 0674244f5c9f4bd2cb362af98df4bcb8da58c2a1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 19 Feb 2015 14:30:58 -0800 Subject: [PATCH] Always create new window when opening w/ no path Fixes #5631 --- spec/integration/startup-spec.coffee | 6 ++++++ src/browser/atom-application.coffee | 11 +++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/integration/startup-spec.coffee b/spec/integration/startup-spec.coffee index c2b1b960c..3161cd932 100644 --- a/spec/integration/startup-spec.coffee +++ b/spec/integration/startup-spec.coffee @@ -142,3 +142,9 @@ describe "Starting Atom", -> client .waitForExist("atom-workspace") .waitForPaneItemCount(1, 5000) + + # Opening with no file paths always creates a new window, even if + # existing windows have no project paths. + .waitForNewWindow(-> + @startAnotherAtom([], ATOM_HOME: AtomHome) + , 5000) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index 32e8ca293..7324aa460 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -361,12 +361,11 @@ class AtomApplication # Default to using the specified window or the last focused window currentWindow = window ? @lastFocusedWindow - - if pathsToOpen.every((pathToOpen) -> fs.statSyncNoException(pathToOpen).isFile?()) - existingWindow ?= currentWindow - - unless currentWindow?.projectPaths?.length > 0 - existingWindow ?= currentWindow + stats = (fs.statSyncNoException(pathToOpen) for pathToOpen in pathsToOpen) + existingWindow ?= currentWindow if ( + stats.every((stat) -> stat.isFile?()) or + stats.some((stat) -> stat.isDirectory?()) and not currentWindow?.hasProjectPath() + ) if existingWindow? openedWindow = existingWindow