Merge pull request #5618 from atom/mb-multi-folder-regressions

Fix multi-folder regressions
This commit is contained in:
Max Brunsfeld
2015-02-18 11:37:15 -08:00
4 changed files with 39 additions and 10 deletions

View File

@@ -121,3 +121,24 @@ 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)
it "always opens with a single untitled buffer when launched w/ no path", ->
runAtom [], {ATOM_HOME: AtomHome}, (client) ->
client
.waitForExist("atom-workspace")
.waitForPaneItemCount(1, 5000)
runAtom [], {ATOM_HOME: AtomHome}, (client) ->
client
.waitForExist("atom-workspace")
.waitForPaneItemCount(1, 5000)

View File

@@ -96,7 +96,7 @@ class Atom extends Model
filename = 'spec'
when 'editor'
{initialPaths} = @getLoadSettings()
if initialPaths
if initialPaths?.length > 0
sha1 = crypto.createHash('sha1').update(initialPaths.join("\n")).digest('hex')
filename = "editor-#{sha1}"

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

View File

@@ -18,8 +18,9 @@ class AtomWindow
isSpec: null
constructor: (settings={}) ->
{@resourcePath, pathToOpen, @locationsToOpen, @isSpec, @exitWhenDone, @safeMode, @devMode} = settings
@locationsToOpen ?= [{pathToOpen}] if pathToOpen
{@resourcePath, pathToOpen, locationsToOpen, @isSpec, @exitWhenDone, @safeMode, @devMode} = settings
locationsToOpen ?= [{pathToOpen}] if pathToOpen
locationsToOpen ?= []
# Normalize to make sure drive letter case is consistent on Windows
@resourcePath = path.normalize(@resourcePath) if @resourcePath
@@ -52,11 +53,13 @@ class AtomWindow
@constructor.includeShellLoadTime = false
loadSettings.shellLoadTime ?= Date.now() - global.shellStartTime
loadSettings.initialPaths = for {pathToOpen} in (@locationsToOpen ? [])
if fs.statSyncNoException(pathToOpen).isFile?()
path.dirname(pathToOpen)
else
pathToOpen
loadSettings.initialPaths =
for {pathToOpen} in locationsToOpen when pathToOpen
if fs.statSyncNoException(pathToOpen).isFile?()
path.dirname(pathToOpen)
else
pathToOpen
loadSettings.initialPaths.sort()
@projectPaths = loadSettings.initialPaths
@@ -70,7 +73,7 @@ class AtomWindow
@browserWindow.loadUrl @getUrl(loadSettings)
@browserWindow.focusOnWebView() if @isSpec
@openLocations(@locationsToOpen) unless @isSpecWindow()
@openLocations(locationsToOpen) unless @isSpecWindow()
getUrl: (loadSettingsObj) ->
# Ignore the windowState when passing loadSettings via URL, since it could