mirror of
https://github.com/atom/atom.git
synced 2026-02-09 14:15:24 -05:00
Remove @path var from project
This commit is contained in:
@@ -6,7 +6,6 @@ Directory = require 'directory'
|
||||
|
||||
module.exports =
|
||||
class Project
|
||||
path: null
|
||||
rootDirectory: null
|
||||
buffers: null
|
||||
|
||||
@@ -15,16 +14,15 @@ class Project
|
||||
@buffers = []
|
||||
|
||||
getPath: ->
|
||||
@path
|
||||
@rootDirectory?.path
|
||||
|
||||
setPath: (path) ->
|
||||
@rootDirectory.off() if @rootDirectory
|
||||
@rootDirectory?.off()
|
||||
|
||||
if path?
|
||||
@path = if fs.isDirectory(path) then path else fs.directory(path)
|
||||
@rootDirectory = new Directory(@path)
|
||||
directory = if fs.isDirectory(path) then path else fs.directory(path)
|
||||
@rootDirectory = new Directory(directory)
|
||||
else
|
||||
@path = null
|
||||
@rootDirectory = null
|
||||
|
||||
@trigger "path-change"
|
||||
@@ -33,8 +31,7 @@ class Project
|
||||
@rootDirectory
|
||||
|
||||
getFilePaths: ->
|
||||
projectPath = @path
|
||||
fs.async.listTree(@path).pipe (paths) =>
|
||||
fs.async.listTree(@getPath()).pipe (paths) =>
|
||||
@relativize(path) for path in paths when fs.isFile(path)
|
||||
|
||||
open: (filePath) ->
|
||||
@@ -51,11 +48,11 @@ class Project
|
||||
buffer
|
||||
|
||||
resolve: (filePath) ->
|
||||
filePath = fs.join(@path, filePath) unless filePath[0] == '/'
|
||||
filePath = fs.join(@getPath(), filePath) unless filePath[0] == '/'
|
||||
fs.absolute filePath
|
||||
|
||||
relativize: (fullPath) ->
|
||||
fullPath.replace(@path, "").replace(/^\//, '')
|
||||
fullPath.replace(@getPath(), "").replace(/^\//, '')
|
||||
|
||||
bufferWithId: (id) ->
|
||||
return buffer for buffer in @buffers when buffer.id == id
|
||||
|
||||
@@ -39,11 +39,10 @@ class RootView extends View
|
||||
|
||||
@setTitle()
|
||||
@project = new Project(pathToOpen)
|
||||
if pathToOpen? and fs.isFile(pathToOpen)
|
||||
@open(pathToOpen)
|
||||
@open(pathToOpen) if fs.isFile(pathToOpen)
|
||||
|
||||
serialize: ->
|
||||
projectPath: @project?.path
|
||||
projectPath: @project?.getPath()
|
||||
panesViewState: @panes.children().view()?.serialize()
|
||||
extensionStates: @serializeExtensions()
|
||||
|
||||
@@ -57,7 +56,7 @@ class RootView extends View
|
||||
@setTitle(@project?.getPath())
|
||||
|
||||
@on 'active-editor-path-change', (e, path) =>
|
||||
@project.setPath(path) unless @project.getPath()
|
||||
@project.setPath(path) unless @project.getRootDirectory()
|
||||
@setTitle(path)
|
||||
|
||||
afterAttach: (onDom) ->
|
||||
|
||||
Reference in New Issue
Block a user