From a0a4dac5712228820f44640bf29b7f4a2923cc45 Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Tue, 3 Mar 2015 16:48:58 -0800 Subject: [PATCH] Fix a bug when a URI is passed to atom.project.removePath(). --- spec/project-spec.coffee | 17 +++++++++++++++++ src/project.coffee | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/project-spec.coffee b/spec/project-spec.coffee index 476d731ee..02ea81ff4 100644 --- a/spec/project-spec.coffee +++ b/spec/project-spec.coffee @@ -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")) diff --git a/src/project.coffee b/src/project.coffee index b0c1ffb0b..8958b6d43 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -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