Root view sets project's path using project.setPath(path)

This commit is contained in:
Corey Johnson 2012-05-01 10:00:53 -07:00
parent ee51a72721
commit d04be05e95
4 changed files with 17 additions and 6 deletions

View File

@ -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()

View File

@ -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'

View File

@ -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

View File

@ -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()