Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
74f0c4b2
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
74f0c4b2
编写于
6月 19, 2017
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FileStat.root
上级
7aeeeecd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
24 deletion
+16
-24
src/vs/workbench/parts/files/browser/views/explorerView.ts
src/vs/workbench/parts/files/browser/views/explorerView.ts
+3
-3
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
+2
-10
src/vs/workbench/parts/files/common/explorerModel.ts
src/vs/workbench/parts/files/common/explorerModel.ts
+6
-6
src/vs/workbench/parts/files/test/browser/explorerModel.test.ts
.../workbench/parts/files/test/browser/explorerModel.test.ts
+5
-5
未找到文件。
src/vs/workbench/parts/files/browser/views/explorerView.ts
浏览文件 @
74f0c4b2
...
...
@@ -431,7 +431,7 @@ export class ExplorerView extends CollapsibleView {
// Add the new file to its parent (Model)
parents
.
forEach
(
p
=>
{
const
childElement
=
FileStat
.
create
(
addedElement
);
const
childElement
=
FileStat
.
create
(
addedElement
,
p
.
root
);
p
.
removeChild
(
childElement
);
// make sure to remove any previous version of the file if any
p
.
addChild
(
childElement
);
// Refresh the Parent (View)
...
...
@@ -719,7 +719,7 @@ export class ExplorerView extends CollapsibleView {
// Load Root Stat with given target path configured
const
promise
=
this
.
fileService
.
resolveFiles
(
targetsToResolve
).
then
(
stats
=>
{
// Convert to model
const
modelStats
=
stats
.
map
((
stat
,
index
)
=>
FileStat
.
create
(
stat
,
targetsToResolve
[
index
].
options
.
resolveTo
));
const
modelStats
=
stats
.
map
((
stat
,
index
)
=>
FileStat
.
create
(
stat
,
targetsToResolve
[
index
].
root
.
resource
,
targetsToResolve
[
index
].
options
.
resolveTo
));
// Subsequent refresh: Merge stat into our local model and refresh tree
modelStats
.
forEach
((
modelStat
,
index
)
=>
FileStat
.
mergeLocalWithDisk
(
modelStat
,
this
.
model
.
roots
[
index
]));
...
...
@@ -806,7 +806,7 @@ export class ExplorerView extends CollapsibleView {
return
this
.
fileService
.
resolveFile
(
rootUri
,
options
).
then
(
stat
=>
{
// Convert to model
const
modelStat
=
FileStat
.
create
(
stat
,
options
.
resolveTo
);
const
modelStat
=
FileStat
.
create
(
stat
,
rootUri
,
options
.
resolveTo
);
const
root
=
this
.
model
.
roots
.
filter
(
r
=>
r
.
resource
.
toString
()
===
rootUri
.
toString
()).
pop
();
// Update Input with disk Stat
FileStat
.
mergeLocalWithDisk
(
modelStat
,
root
);
...
...
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
浏览文件 @
74f0c4b2
...
...
@@ -71,15 +71,7 @@ export class FileDataSource implements IDataSource {
return
'
model
'
;
}
// TODO@Isidor each file stat should have a reference to the root, this way you do not have to walk up the parent chain
let
parent
=
stat
.
parent
;
let
depth
=
0
;
while
(
parent
)
{
parent
=
parent
.
parent
;
depth
++
;
}
return
`
${
depth
}
:
${
stat
.
getId
()}
`
;
return
`
${
stat
.
root
.
toString
()}
:
${
stat
.
getId
()}
`
;
}
public
hasChildren
(
tree
:
ITree
,
stat
:
FileStat
|
Model
):
boolean
{
...
...
@@ -103,7 +95,7 @@ export class FileDataSource implements IDataSource {
const
promise
=
this
.
fileService
.
resolveFile
(
stat
.
resource
,
{
resolveSingleChildDescendants
:
true
}).
then
(
dirStat
=>
{
// Convert to view model
const
modelDirStat
=
FileStat
.
create
(
dirStat
);
const
modelDirStat
=
FileStat
.
create
(
dirStat
,
stat
.
root
);
// Add children to folder
for
(
let
i
=
0
;
i
<
modelDirStat
.
children
.
length
;
i
++
)
{
...
...
src/vs/workbench/parts/files/common/explorerModel.ts
浏览文件 @
74f0c4b2
...
...
@@ -25,7 +25,7 @@ export class Model {
private
_roots
:
FileStat
[];
constructor
(
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
)
{
const
setRoots
=
()
=>
this
.
_roots
=
this
.
contextService
.
getWorkspace2
().
roots
.
map
(
uri
=>
new
FileStat
(
uri
));
const
setRoots
=
()
=>
this
.
_roots
=
this
.
contextService
.
getWorkspace2
().
roots
.
map
(
uri
=>
new
FileStat
(
uri
,
uri
));
this
.
contextService
.
onDidChangeWorkspaceRoots
(()
=>
setRoots
());
setRoots
();
}
...
...
@@ -67,7 +67,7 @@ export class FileStat implements IFileStat {
public
isDirectoryResolved
:
boolean
;
constructor
(
resource
:
URI
,
isDirectory
?:
boolean
,
hasChildren
?:
boolean
,
name
:
string
=
paths
.
basename
(
resource
.
fsPath
),
mtime
?:
number
,
etag
?:
string
)
{
constructor
(
resource
:
URI
,
public
root
:
URI
,
isDirectory
?:
boolean
,
hasChildren
?:
boolean
,
name
:
string
=
paths
.
basename
(
resource
.
fsPath
),
mtime
?:
number
,
etag
?:
string
)
{
this
.
resource
=
resource
;
this
.
name
=
name
;
this
.
isDirectory
=
!!
isDirectory
;
...
...
@@ -87,8 +87,8 @@ export class FileStat implements IFileStat {
return
this
.
resource
.
toString
();
}
public
static
create
(
raw
:
IFileStat
,
resolveTo
?:
URI
[]):
FileStat
{
const
stat
=
new
FileStat
(
raw
.
resource
,
raw
.
isDirectory
,
raw
.
hasChildren
,
raw
.
name
,
raw
.
mtime
,
raw
.
etag
);
public
static
create
(
raw
:
IFileStat
,
r
oot
:
URI
,
r
esolveTo
?:
URI
[]):
FileStat
{
const
stat
=
new
FileStat
(
raw
.
resource
,
r
oot
,
r
aw
.
isDirectory
,
raw
.
hasChildren
,
raw
.
name
,
raw
.
mtime
,
raw
.
etag
);
// Recursively add children if present
if
(
stat
.
isDirectory
)
{
...
...
@@ -103,7 +103,7 @@ export class FileStat implements IFileStat {
// Recurse into children
if
(
raw
.
children
)
{
for
(
let
i
=
0
,
len
=
raw
.
children
.
length
;
i
<
len
;
i
++
)
{
const
child
=
FileStat
.
create
(
raw
.
children
[
i
],
resolveTo
);
const
child
=
FileStat
.
create
(
raw
.
children
[
i
],
r
oot
,
r
esolveTo
);
child
.
parent
=
stat
;
stat
.
children
.
push
(
child
);
stat
.
hasChildren
=
stat
.
children
.
length
>
0
;
...
...
@@ -313,7 +313,7 @@ export class NewStatPlaceholder extends FileStat {
private
directoryPlaceholder
:
boolean
;
constructor
(
isDirectory
:
boolean
)
{
super
(
URI
.
file
(
''
));
super
(
URI
.
file
(
''
)
,
URI
.
file
(
''
)
);
this
.
id
=
NewStatPlaceholder
.
ID
++
;
this
.
isDirectoryResolved
=
isDirectory
;
...
...
src/vs/workbench/parts/files/test/browser/explorerModel.test.ts
浏览文件 @
74f0c4b2
...
...
@@ -14,7 +14,7 @@ import { validateFileName } from 'vs/workbench/parts/files/browser/fileActions';
import
{
FileStat
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
function
createStat
(
path
,
name
,
isFolder
,
hasChildren
,
size
,
mtime
)
{
return
new
FileStat
(
toResource
(
path
),
isFolder
,
hasChildren
,
name
,
mtime
);
return
new
FileStat
(
toResource
(
path
),
toResource
(
path
),
isFolder
,
hasChildren
,
name
,
mtime
);
}
function
toResource
(
path
)
{
...
...
@@ -246,20 +246,20 @@ suite('Files - View Model', () => {
test
(
'
Merge Local with Disk
'
,
function
()
{
const
d
=
new
Date
().
toUTCString
();
const
merge1
=
new
FileStat
(
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path/to
'
)),
true
,
false
,
'
to
'
,
Date
.
now
(),
d
);
const
merge2
=
new
FileStat
(
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path/to
'
)),
true
,
false
,
'
to
'
,
Date
.
now
(),
new
Date
(
0
).
toUTCString
());
const
merge1
=
new
FileStat
(
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path/to
'
)),
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path
'
)),
true
,
false
,
'
to
'
,
Date
.
now
(),
d
);
const
merge2
=
new
FileStat
(
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path/to
'
)),
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path
'
)),
true
,
false
,
'
to
'
,
Date
.
now
(),
new
Date
(
0
).
toUTCString
());
// Merge Properties
FileStat
.
mergeLocalWithDisk
(
merge2
,
merge1
);
assert
.
strictEqual
(
merge1
.
mtime
,
merge2
.
mtime
);
// Merge Child when isDirectoryResolved=false is a no-op
merge2
.
addChild
(
new
FileStat
(
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path/to/foo.html
'
)),
true
,
false
,
'
foo.html
'
,
Date
.
now
(),
d
));
merge2
.
addChild
(
new
FileStat
(
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path/to/foo.html
'
)),
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path
'
)),
true
,
false
,
'
foo.html
'
,
Date
.
now
(),
d
));
FileStat
.
mergeLocalWithDisk
(
merge2
,
merge1
);
assert
.
strictEqual
(
merge1
.
children
.
length
,
0
);
// Merge Child with isDirectoryResolved=true
const
child
=
new
FileStat
(
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path/to/foo.html
'
)),
true
,
false
,
'
foo.html
'
,
Date
.
now
(),
d
);
const
child
=
new
FileStat
(
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path/to/foo.html
'
)),
URI
.
file
(
join
(
'
C:
\\
'
,
'
/path
'
)),
true
,
false
,
'
foo.html
'
,
Date
.
now
(),
d
);
merge2
.
removeChild
(
child
);
merge2
.
addChild
(
child
);
merge2
.
isDirectoryResolved
=
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录