Fix a bug when a URI is passed to atom.project.removePath().

This commit is contained in:
Michael Bolin
2015-03-03 16:48:58 -08:00
parent 3952831ff1
commit a0a4dac571
2 changed files with 20 additions and 1 deletions

View File

@@ -436,6 +436,23 @@ describe "Project", ->
expect(atom.project.getPaths()).toEqual([path.join(__dirname, "..", "src")])
expect(atom.project.getRepositories()[0].isSubmodule("src")).toBe false
it "removes a path that is represented as a URI", ->
ftpURI = "ftp://example.com/some/folder"
directoryProvider =
directoryForURISync: (uri) ->
# Dummy implementation of Directory for which GitRepositoryProvider
# will not try to create a GitRepository.
getPath: -> ftpURI
getSubdirectory: -> {}
isRoot: -> true
off: ->
atom.packages.serviceHub.provide(
"atom.directory-provider", "0.1.0", directoryProvider)
atom.project.setPaths([ftpURI])
expect(atom.project.getPaths()).toEqual [ftpURI]
atom.project.removePath(ftpURI)
expect(atom.project.getPaths()).toEqual []
describe ".relativize(path)", ->
it "returns the path, relative to whichever root directory it is inside of", ->
atom.project.addPath(temp.mkdirSync("another-path"))

View File

@@ -221,7 +221,9 @@ class Project extends Model
#
# * `projectPath` {String} The path to remove.
removePath: (projectPath) ->
projectPath = path.normalize(projectPath)
# The projectPath may be a URI, in which case it should not be normalized.
unless projectPath in @getPaths()
projectPath = path.normalize(projectPath)
indexToRemove = null
for directory, i in @rootDirectories