Merge pull request #6977 from atom/revert-6813-local-initial-paths

Revert "Initial paths shouldn't be normalized on save and restore (co…
This commit is contained in:
Max Brunsfeld
2015-05-27 10:27:55 -07:00
7 changed files with 15 additions and 62 deletions

View File

@@ -31,12 +31,6 @@ describe "DefaultDirectoryProvider", ->
directory = provider.directoryForURISync(file)
expect(directory.getPath()).toEqual tmp
it "creates a Directory with a path as a uri when passed a uri", ->
provider = new DefaultDirectoryProvider()
uri = 'remote://server:6792/path/to/a/dir'
directory = provider.directoryForURISync(uri)
expect(directory.getPath()).toEqual uri
describe ".directoryForURI(uri)", ->
it "returns a Promise that resolves to a Directory with a path that matches the uri", ->
provider = new DefaultDirectoryProvider()

View File

@@ -227,13 +227,3 @@ describe "Starting Atom", ->
[tempDirPath]
[otherTempDirPath]
].sort()
describe "opening a remote directory", ->
it "opens the parent directory and creates an empty text editor", ->
remoteDirectory = 'remote://server:3437/some/directory/path'
runAtom [remoteDirectory], {ATOM_HOME: atomHome}, (client) ->
client
.waitForWindowCount(1, 1000)
.waitForExist("atom-workspace", 5000)
.treeViewRootDirectories()
.then ({value}) -> expect(value).toEqual([remoteDirectory])

View File

@@ -293,14 +293,3 @@ describe "Window", ->
pathToOpen = __dirname
atom.getCurrentWindow().send 'message', 'open-locations', [{pathToOpen}]
expect(atom.workspace.open.callCount).toBe 0
describe "when the opened path is a uri", ->
it "adds it to the project's paths as is", ->
pathToOpen = 'remote://server:7644/some/dir/path'
atom.getCurrentWindow().send 'message', 'open-locations', [{pathToOpen}]
waitsFor ->
atom.project.getPaths().length is 1
runs ->
expect(atom.project.getPaths()[0]).toBe pathToOpen

View File

@@ -369,12 +369,7 @@ class AtomApplication
# :windowDimensions - Object with height and width keys.
# :window - {AtomWindow} to open file paths in.
openPaths: ({pathsToOpen, pidToKillWhenClosed, newWindow, devMode, safeMode, apiPreviewMode, windowDimensions, profileStartup, window}={}) ->
pathsToOpen = pathsToOpen.map (pathToOpen) ->
if fs.existsSync(pathToOpen)
fs.normalize(pathToOpen)
else
pathToOpen
pathsToOpen = (fs.normalize(pathToOpen) for pathToOpen in pathsToOpen)
locationsToOpen = (@locationForPathToOpen(pathToOpen) for pathToOpen in pathsToOpen)
unless pidToKillWhenClosed or newWindow
@@ -523,7 +518,6 @@ class AtomApplication
locationForPathToOpen: (pathToOpen) ->
return {pathToOpen} unless pathToOpen
return {pathToOpen} if url.parse(pathToOpen).protocol?
return {pathToOpen} if fs.existsSync(pathToOpen)
pathToOpen = pathToOpen.replace(/[:\s]+$/, '')

View File

@@ -5,7 +5,6 @@ app = require 'app'
fs = require 'fs-plus'
path = require 'path'
yargs = require 'yargs'
url = require 'url'
nslog = require 'nslog'
console.log = nslog
@@ -46,11 +45,9 @@ start = ->
cwd = args.executedFrom?.toString() or process.cwd()
args.pathsToOpen = args.pathsToOpen.map (pathToOpen) ->
normalizedPath = fs.normalize(pathToOpen)
if url.parse(pathToOpen).protocol?
pathToOpen
else if cwd
path.resolve(cwd, normalizedPath)
pathToOpen = fs.normalize(pathToOpen)
if cwd
path.resolve(cwd, pathToOpen)
else
path.resolve(pathToOpen)

View File

@@ -1,7 +1,6 @@
{Directory} = require 'pathwatcher'
fs = require 'fs-plus'
path = require 'path'
url = require 'url'
module.exports =
class DefaultDirectoryProvider
@@ -15,22 +14,14 @@ class DefaultDirectoryProvider
# * {Directory} if the given URI is compatible with this provider.
# * `null` if the given URI is not compatibile with this provider.
directoryForURISync: (uri) ->
normalizedPath = path.normalize(uri)
{protocol} = url.parse(uri)
directoryPath = if protocol?
uri
else if not fs.isDirectorySync(normalizedPath) and fs.isDirectorySync(path.dirname(normalizedPath))
path.dirname(normalizedPath)
else
normalizedPath
projectPath = path.normalize(uri)
# TODO: Stop normalizing the path in pathwatcher's Directory.
directory = new Directory(directoryPath)
if protocol?
directory.path = directoryPath
if fs.isCaseInsensitive()
directory.lowerCasePath = directoryPath.toLowerCase()
directory
directoryPath = if not fs.isDirectorySync(projectPath) and fs.isDirectorySync(path.dirname(projectPath))
path.dirname(projectPath)
else
projectPath
new Directory(directoryPath)
# Public: Create a Directory that corresponds to the specified URI.
#

View File

@@ -5,7 +5,6 @@ ipc = require 'ipc'
shell = require 'shell'
{Subscriber} = require 'emissary'
fs = require 'fs-plus'
url = require 'url'
# Handles low-level events related to the window.
module.exports =
@@ -24,13 +23,12 @@ class WindowEventHandler
if pathToOpen? and needsProjectPaths
if fs.existsSync(pathToOpen)
atom.project.addPath(pathToOpen)
else if fs.existsSync(path.dirname(pathToOpen))
atom.project.addPath(path.dirname(pathToOpen))
else
atom.project.addPath(pathToOpen)
dirToOpen = path.dirname(pathToOpen)
if fs.existsSync(dirToOpen)
atom.project.addPath(dirToOpen)
{protocol} = url.parse(pathToOpen)
unless fs.isDirectorySync(pathToOpen) or protocol?
unless fs.isDirectorySync(pathToOpen)
atom.workspace?.open(pathToOpen, {initialLine, initialColumn})
return