mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Merge pull request #13752 from atom/revert-13725-normalize-disk-drive-letter
Revert "Normalize disk drive letter in path on Windows"
This commit is contained in:
@@ -28,15 +28,6 @@ describe "DefaultDirectoryProvider", ->
|
||||
directory = provider.directoryForURISync(nonNormalizedPath)
|
||||
expect(directory.getPath()).toEqual tmp
|
||||
|
||||
it "normalizes disk drive letter in Windows path", ->
|
||||
provider = new DefaultDirectoryProvider()
|
||||
nonNormalizedPath = tmp[0].toLowerCase()+tmp.slice(1)
|
||||
expect(!tmp.search(/^[a-z]:/)).toBe false
|
||||
expect(!nonNormalizedPath.search(/^[a-z]:/)).toBe true
|
||||
|
||||
directory = provider.directoryForURISync(nonNormalizedPath)
|
||||
expect(directory.getPath()).toEqual tmp
|
||||
|
||||
it "creates a Directory for its parent dir when passed a file", ->
|
||||
provider = new DefaultDirectoryProvider()
|
||||
file = path.join(tmp, "example.txt")
|
||||
|
||||
@@ -614,7 +614,3 @@ describe "Project", ->
|
||||
|
||||
randomPath = path.join("some", "random", "path")
|
||||
expect(atom.project.contains(randomPath)).toBe false
|
||||
|
||||
describe ".resolvePath(uri)", ->
|
||||
it "normalizes disk drive letter in passed Windows path", ->
|
||||
expect(atom.project.resolvePath("d:\file.txt")).toEqual "D:\file.txt"
|
||||
|
||||
@@ -15,7 +15,7 @@ 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 = @normalizePath(uri)
|
||||
normalizedPath = path.normalize(uri)
|
||||
{host} = url.parse(uri)
|
||||
directoryPath = if host
|
||||
uri
|
||||
@@ -42,15 +42,3 @@ class DefaultDirectoryProvider
|
||||
# * `null` if the given URI is not compatibile with this provider.
|
||||
directoryForURI: (uri) ->
|
||||
Promise.resolve(@directoryForURISync(uri))
|
||||
|
||||
# Public: Normalizes path.
|
||||
#
|
||||
# * `uri` {String} The path that should be normalized.
|
||||
#
|
||||
# Returns a {String} with normalized path.
|
||||
normalizePath: (uri) ->
|
||||
# Normalize disk drive letter on Windows to avoid opening two buffers for the same file
|
||||
pathWithNormalizedDiskDriveLetter = uri
|
||||
if matchData = uri.match(/^([A-Za-z]):/)
|
||||
pathWithNormalizedDiskDriveLetter = "#{matchData[1].toUpperCase()}#{uri.slice(1)}"
|
||||
path.normalize(pathWithNormalizedDiskDriveLetter)
|
||||
|
||||
@@ -208,7 +208,7 @@ class Project extends Model
|
||||
removePath: (projectPath) ->
|
||||
# The projectPath may be a URI, in which case it should not be normalized.
|
||||
unless projectPath in @getPaths()
|
||||
projectPath = @defaultDirectoryProvider.normalizePath(projectPath)
|
||||
projectPath = path.normalize(projectPath)
|
||||
|
||||
indexToRemove = null
|
||||
for directory, i in @rootDirectories
|
||||
@@ -236,10 +236,11 @@ class Project extends Model
|
||||
uri
|
||||
else
|
||||
if fs.isAbsolute(uri)
|
||||
@defaultDirectoryProvider.normalizePath(fs.resolveHome(uri))
|
||||
path.normalize(fs.resolveHome(uri))
|
||||
|
||||
# TODO: what should we do here when there are multiple directories?
|
||||
else if projectPath = @getPaths()[0]
|
||||
@defaultDirectoryProvider.normalizePath(fs.resolveHome(path.join(projectPath, uri)))
|
||||
path.normalize(fs.resolveHome(path.join(projectPath, uri)))
|
||||
else
|
||||
undefined
|
||||
|
||||
|
||||
Reference in New Issue
Block a user