Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6a1366de
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,发现更多精彩内容 >>
提交
6a1366de
编写于
6月 15, 2017
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
explorerView: remove use of root fully
上级
0bbdf364
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
45 deletion
+45
-45
src/vs/workbench/parts/files/browser/views/explorerView.ts
src/vs/workbench/parts/files/browser/views/explorerView.ts
+40
-37
src/vs/workbench/parts/files/common/explorerModel.ts
src/vs/workbench/parts/files/common/explorerModel.ts
+5
-8
未找到文件。
src/vs/workbench/parts/files/browser/views/explorerView.ts
浏览文件 @
6a1366de
...
...
@@ -340,10 +340,6 @@ export class ExplorerView extends CollapsibleView {
return
toResource
(
input
,
{
supportSideBySide
:
true
,
filter
:
'
file
'
});
}
private
get
root
():
FileStat
{
return
this
.
explorerViewer
?
(
<
FileStat
>
this
.
explorerViewer
.
getInput
())
:
null
;
}
private
get
isCreated
():
boolean
{
return
this
.
explorerViewer
&&
this
.
explorerViewer
.
getInput
();
}
...
...
@@ -687,7 +683,11 @@ export class ExplorerView extends CollapsibleView {
}
private
doRefresh
():
TPromise
<
void
>
{
const
targetsToResolve
:
URI
[]
=
[];
const
targetsToResolve
:
{
root
:
FileStat
,
resource
:
URI
,
options
:
{
resolveTo
:
URI
[]
}
}[]
=
[];
this
.
model
.
roots
.
forEach
(
root
=>
{
const
rootAndTargets
=
{
root
,
resource
:
root
.
resource
,
options
:
{
resolveTo
:
[]
}
};
targetsToResolve
.
push
(
rootAndTargets
);
});
let
targetsToExpand
:
URI
[]
=
[];
if
(
this
.
settings
[
ExplorerView
.
MEMENTO_EXPANDED_FOLDER_RESOURCES
])
{
...
...
@@ -698,48 +698,50 @@ export class ExplorerView extends CollapsibleView {
if
(
!
this
.
isCreated
)
{
const
activeFile
=
this
.
getActiveFile
();
if
(
activeFile
)
{
targetsToResolve
.
push
(
activeFile
);
const
root
=
this
.
contextService
.
getRoot
(
activeFile
);
if
(
root
)
{
const
found
=
targetsToResolve
.
filter
(
t
=>
t
.
root
.
resource
.
toString
()
===
root
.
toString
()).
pop
();
found
.
options
.
resolveTo
.
push
(
activeFile
);
}
}
if
(
targetsToExpand
.
length
)
{
targetsToResolve
.
push
(...
targetsToExpand
);
}
targetsToExpand
.
forEach
(
toExpand
=>
{
const
root
=
this
.
contextService
.
getRoot
(
toExpand
);
if
(
root
)
{
const
found
=
targetsToResolve
.
filter
(
ttr
=>
ttr
.
resource
.
toString
()
===
root
.
toString
()).
pop
();
found
.
options
.
resolveTo
.
push
(
toExpand
);
}
});
}
// Subsequent refresh: Receive targets through expanded folders in tree
else
{
this
.
getResolvedDirectories
(
this
.
root
,
targetsToResolve
);
targetsToResolve
.
forEach
(
t
=>
{
this
.
getResolvedDirectories
(
t
.
root
,
t
.
options
.
resolveTo
);
});
}
// Load Root Stat with given target path configured
const
options
:
IResolveFileOptions
=
{
resolveTo
:
targetsToResolve
};
const
promise
=
this
.
fileService
.
resolveFile
(
this
.
contextService
.
getWorkspace
().
resource
,
options
).
then
(
stat
=>
{
let
explorerPromise
:
TPromise
<
void
>
;
const
promise
=
this
.
fileService
.
resolveFiles
(
targetsToResolve
).
then
(
stats
=>
{
// Convert to model
const
modelStat
=
FileStat
.
create
(
stat
,
options
.
resolveTo
);
// First time refresh: The stat becomes the input of the viewer
if
(
!
this
.
isCreated
)
{
explorerPromise
=
this
.
explorerViewer
.
setInput
(
modelStat
).
then
(()
=>
{
// Make sure to expand all folders that where expanded in the previous session
if
(
targetsToExpand
)
{
return
this
.
explorerViewer
.
expandAll
(
targetsToExpand
.
map
(
expand
=>
this
.
root
.
find
(
expand
)));
}
const
modelStats
=
stats
.
map
((
stat
,
index
)
=>
FileStat
.
create
(
stat
,
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
]));
return
TPromise
.
as
(
null
);
}
);
if
(
this
.
isCreated
)
{
return
this
.
explorerViewer
.
refresh
(
);
}
// Subsequent refresh: Merge stat into our local model and refresh tree
else
{
FileStat
.
mergeLocalWithDisk
(
modelStat
,
this
.
root
);
// First time refresh: The stat becomes the input of the viewer
return
this
.
explorerViewer
.
setInput
(
this
.
model
).
then
(()
=>
{
explorerPromise
=
this
.
explorerViewer
.
refresh
(
this
.
root
);
}
// Make sure to expand all folders that where expanded in the previous session
if
(
targetsToExpand
)
{
return
this
.
explorerViewer
.
expandAll
(
targetsToExpand
.
map
(
expand
=>
this
.
model
.
findFirst
(
expand
)));
}
return
explorerPromise
;
return
TPromise
.
as
(
null
);
});
},
(
e
:
any
)
=>
TPromise
.
wrapError
(
e
));
this
.
progressService
.
showWhile
(
promise
,
this
.
partService
.
isCreated
()
?
800
:
3200
/* less ugly initial startup */
);
...
...
@@ -796,23 +798,24 @@ export class ExplorerView extends CollapsibleView {
return
TPromise
.
as
(
null
);
}
const
fileStat
=
this
.
root
.
find
(
resource
);
const
fileStat
=
this
.
model
.
findFirst
(
resource
);
if
(
fileStat
)
{
return
this
.
doSelect
(
fileStat
,
reveal
);
}
// Stat needs to be resolved first and then revealed
const
options
:
IResolveFileOptions
=
{
resolveTo
:
[
resource
]
};
return
this
.
fileService
.
resolveFile
(
this
.
contextService
.
getWorkspace
().
resource
,
options
).
then
(
stat
=>
{
const
rootUri
=
this
.
contextService
.
getRoot
(
resource
);
return
this
.
fileService
.
resolveFile
(
rootUri
,
options
).
then
(
stat
=>
{
// Convert to model
const
modelStat
=
FileStat
.
create
(
stat
,
options
.
resolveTo
);
const
root
=
this
.
model
.
roots
.
filter
(
r
=>
r
.
resource
.
toString
()
===
rootUri
.
toString
()).
pop
();
// Update Input with disk Stat
FileStat
.
mergeLocalWithDisk
(
modelStat
,
this
.
root
);
FileStat
.
mergeLocalWithDisk
(
modelStat
,
root
);
// Select and Reveal
return
this
.
explorerViewer
.
refresh
(
this
.
root
).
then
(()
=>
this
.
doSelect
(
this
.
root
.
find
(
resource
),
reveal
));
return
this
.
explorerViewer
.
refresh
(
root
).
then
(()
=>
this
.
doSelect
(
root
.
find
(
resource
),
reveal
));
},
(
e
:
any
)
=>
this
.
messageService
.
show
(
Severity
.
Error
,
e
));
}
...
...
src/vs/workbench/parts/files/common/explorerModel.ts
浏览文件 @
6a1366de
...
...
@@ -53,11 +53,6 @@ export class Model {
return
null
;
}
public
rootForResource
(
resource
:
URI
):
FileStat
{
// TODO@Isidor temporary until we have a utility method for this
return
this
.
roots
[
0
];
}
}
export
class
FileStat
implements
IFileStat
{
...
...
@@ -148,9 +143,11 @@ export class FileStat implements IFileStat {
// Map resource => stat
const
oldLocalChildren
=
new
ResourceMap
<
FileStat
>
();
local
.
children
.
forEach
((
localChild
:
FileStat
)
=>
{
oldLocalChildren
.
set
(
localChild
.
resource
,
localChild
);
});
if
(
local
.
children
)
{
local
.
children
.
forEach
((
localChild
:
FileStat
)
=>
{
oldLocalChildren
.
set
(
localChild
.
resource
,
localChild
);
});
}
// Clear current children
local
.
children
=
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录