diff --git a/spec/app/project-spec.coffee b/spec/app/project-spec.coffee index c53b33c70..8407459be 100644 --- a/spec/app/project-spec.coffee +++ b/spec/app/project-spec.coffee @@ -73,3 +73,9 @@ describe "Project", -> project.setPath(require.resolve('fixtures/dir/a-dir')) expect(project.getPath()).toEqual require.resolve('fixtures/dir/a-dir') expect(project.getRootDirectory().path).toEqual require.resolve('fixtures/dir/a-dir') + + describe "when path is null", -> + it "sets its path and root directory to null", -> + project.setPath(null) + expect(project.getPath()).toBeNull() + expect(project.getRootDirectory()).toBeNull() diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index a79ddbf14..b6cd762b0 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -52,7 +52,7 @@ describe "RootView", -> it "constructs the view with the same panes", -> rootView = new RootView(viewState) - expect(rootView.project.path).toBeUndefined() + expect(rootView.project.path).toBeNull() expect(rootView.editors().length).toBe 2 expect(rootView.activeEditor().buffer.getText()).toBe buffer.getText() expect(document.title).toBe 'untitled' @@ -407,7 +407,7 @@ describe "RootView", -> it "creates a project if there isn't one yet and the buffer was previously unsaved", -> rootView = new RootView - expect(rootView.project.path).toBeUndefined() + expect(rootView.project.path).toBeNull() rootView.activeEditor().buffer.saveAs('/tmp/ignore-me') expect(rootView.project.path).toBe '/tmp' diff --git a/src/app/project.coffee b/src/app/project.coffee index e54db5516..0eb226331 100644 --- a/src/app/project.coffee +++ b/src/app/project.coffee @@ -18,9 +18,14 @@ class Project @path setPath: (path) -> - @path = if fs.isDirectory(path) then path else fs.directory(path) @rootDirectory.off() if @rootDirectory - @rootDirectory = new Directory(@path) + + if path? + @path = if fs.isDirectory(path) then path else fs.directory(path) + @rootDirectory = new Directory(@path) + else + @path = null + @rootDirectory = null getRootDirectory: -> @rootDirectory diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 652bba5ff..8b6a29d77 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -32,7 +32,7 @@ class RootView extends View @activeEditor().focus() false else - @setTitle(@project?.path) + @setTitle(@project?.getPath()) @on 'active-editor-path-change', (e, path) => @project.setPath(path) unless @project.getPath() @@ -112,7 +112,7 @@ class RootView extends View rootPane?.adjustDimensions() toggleFileFinder: -> - return unless @project.path? + return unless @project.getPath()? if @fileFinder and @fileFinder.parent()[0] @fileFinder.remove()