Reuse current window if it has no project path

Fixes #5615
This commit is contained in:
Max Brunsfeld
2015-02-18 10:29:48 -08:00
parent 2518c40942
commit 39a225821e
2 changed files with 16 additions and 1 deletions

View File

@@ -121,3 +121,13 @@ describe "Starting Atom", ->
projectPaths.push(value[0])
.then ->
expect(projectPaths.sort()).toEqual([tempDirPath, otherTempDirPath].sort())
it "opens the path in the current window if it doesn't have a project path yet", ->
runAtom [], {ATOM_HOME: AtomHome}, (client) ->
client
.waitForExist("atom-workspace")
.startAnotherAtom([tempDirPath], ATOM_HOME: AtomHome)
.waitUntil((->
@title()
.then(({value}) -> value.indexOf(path.basename(tempDirPath)) >= 0)), 5000)
.waitForWindowCount(1, 5000)

View File

@@ -360,8 +360,13 @@ class AtomApplication
existingWindow = @windowForPaths(pathsToOpen, devMode)
# Default to using the specified window or the last focused window
currentWindow = window ? @lastFocusedWindow
if pathsToOpen.every((pathToOpen) -> fs.statSyncNoException(pathToOpen).isFile?())
existingWindow ?= window ? @lastFocusedWindow
existingWindow ?= currentWindow
unless currentWindow?.projectPaths?.length > 0
existingWindow ?= currentWindow
if existingWindow?
openedWindow = existingWindow