mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Root view sets project's path using project.setPath(path)
This commit is contained in:
parent
ee51a72721
commit
d04be05e95
@ -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()
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user