Don't add project paths when opening a file in an existing window

This commit is contained in:
Max Brunsfeld
2015-02-24 12:09:10 -08:00
parent cd9a1ccb9f
commit a1ba470c5b
2 changed files with 26 additions and 13 deletions

View File

@@ -18,9 +18,16 @@ class WindowEventHandler
@subscribe ipc, 'message', (message, detail) ->
switch message
when 'open-locations'
needsProjectPaths = atom.project?.getPaths().length is 0
for {pathToOpen, initialLine, initialColumn} in detail
if pathToOpen and (fs.existsSync(pathToOpen) or fs.existsSync(path.dirname(pathToOpen)))
atom.project?.addPath(pathToOpen)
if pathToOpen? and needsProjectPaths
if fs.existsSync(pathToOpen)
atom.project.addPath(pathToOpen)
else
dirToOpen = path.dirname(pathToOpen)
if fs.existsSync(dirToOpen)
atom.project.addPath(dirToOpen)
unless fs.isDirectorySync(pathToOpen)
atom.workspace?.open(pathToOpen, {initialLine, initialColumn})