mirror of
https://github.com/atom/atom.git
synced 2026-02-10 06:35:00 -05:00
When project's constructor is given a file as its path, it sets its path to the parent directory of the given file
This commit is contained in:
@@ -7,6 +7,8 @@ module.exports =
|
||||
class Directory
|
||||
@idCounter = 0
|
||||
|
||||
path: null
|
||||
|
||||
constructor: (@path) ->
|
||||
@id = ++Directory.idCounter
|
||||
|
||||
|
||||
@@ -6,10 +6,20 @@ Directory = require 'directory'
|
||||
|
||||
module.exports =
|
||||
class Project
|
||||
path: null
|
||||
rootDirectory: null
|
||||
buffers: null
|
||||
|
||||
constructor: (@path) ->
|
||||
constructor: (path) ->
|
||||
@setPath(path)
|
||||
@buffers = []
|
||||
|
||||
getPath: ->
|
||||
@path
|
||||
|
||||
setPath: (path) ->
|
||||
@path = if fs.isDirectory(path) then path else fs.directory(path)
|
||||
@rootDirectory.off() if @rootDirectory
|
||||
@rootDirectory = new Directory(@path)
|
||||
|
||||
getRootDirectory: ->
|
||||
|
||||
@@ -35,14 +35,13 @@ class RootView extends View
|
||||
@setTitle(@project?.path)
|
||||
|
||||
@on 'active-editor-path-change', (e, path) =>
|
||||
@project.path ?= fs.directory(path) if path
|
||||
@project.setPath(path) unless @project.getPath()
|
||||
@setTitle(path)
|
||||
|
||||
|
||||
@commandPanel = new CommandPanel({rootView: this})
|
||||
|
||||
if pathToOpen?
|
||||
@project = new Project(fs.directory(pathToOpen))
|
||||
@project = new Project(pathToOpen)
|
||||
@open(pathToOpen) if fs.isFile(pathToOpen)
|
||||
else
|
||||
@project = new Project(projectPath)
|
||||
|
||||
Reference in New Issue
Block a user