Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c21114d5
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,发现更多精彩内容 >>
提交
c21114d5
编写于
5月 11, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify doInstantiateEditor
上级
b1c59a14
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
32 addition
and
34 deletion
+32
-34
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+32
-34
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
c21114d5
...
...
@@ -91,7 +91,7 @@ export class EditorPart extends Part implements IEditorPart {
private
visibleEditorListeners
:
Function
[][];
private
instantiatedEditors
:
BaseEditor
[][];
private
mapEditorToEditorContainers
:
{
[
editorId
:
string
]:
Builder
;
}[];
private
mapEditor
Loading
PromiseToEditor
:
{
[
editorId
:
string
]:
TPromise
<
BaseEditor
>
;
}[];
private
mapEditor
Instantiation
PromiseToEditor
:
{
[
editorId
:
string
]:
TPromise
<
BaseEditor
>
;
}[];
private
mapEditorCreationPromiseToEditor
:
{
[
editorId
:
string
]:
TPromise
<
BaseEditor
>
;
}[];
private
editorOpenToken
:
number
[];
private
editorSetInputErrorCounter
:
number
[];
...
...
@@ -120,7 +120,7 @@ export class EditorPart extends Part implements IEditorPart {
this
.
instantiatedEditors
=
arrays
.
fill
(
POSITIONS
.
length
,
()
=>
[]);
this
.
mapEditorToEditorContainers
=
arrays
.
fill
(
POSITIONS
.
length
,
()
=>
Object
.
create
(
null
));
this
.
mapEditor
Loading
PromiseToEditor
=
arrays
.
fill
(
POSITIONS
.
length
,
()
=>
Object
.
create
(
null
));
this
.
mapEditor
Instantiation
PromiseToEditor
=
arrays
.
fill
(
POSITIONS
.
length
,
()
=>
Object
.
create
(
null
));
this
.
mapEditorCreationPromiseToEditor
=
arrays
.
fill
(
POSITIONS
.
length
,
()
=>
Object
.
create
(
null
));
this
.
pendingEditorInputsToClose
=
[];
...
...
@@ -143,7 +143,7 @@ export class EditorPart extends Part implements IEditorPart {
// Some conditions under which we prevent the request
if
(
position
===
null
||
// invalid position
Object
.
keys
(
this
.
mapEditor
LoadingPromiseToEditor
[
position
]).
length
>
0
||
// pending editor load
Object
.
keys
(
this
.
mapEditor
InstantiationPromiseToEditor
[
position
]).
length
>
0
||
// pending editor load
Object
.
keys
(
this
.
mapEditorCreationPromiseToEditor
[
position
]).
length
>
0
||
// pending editor create
this
.
sideBySideControl
.
isDragging
()
// pending editor DND
)
{
...
...
@@ -341,44 +341,42 @@ export class EditorPart extends Part implements IEditorPart {
}
private
doInstantiateEditor
(
descriptor
:
EditorDescriptor
,
position
:
Position
):
TPromise
<
BaseEditor
>
{
// Return early if already instantiated
let
instantiatedEditor
=
this
.
instantiatedEditors
[
position
].
filter
(
e
=>
descriptor
.
describes
(
e
))[
0
];
let
loadEditorPromise
:
TPromise
<
BaseEditor
>
;
if
(
!
instantiatedEditor
)
{
if
(
instantiatedEditor
)
{
return
TPromise
.
as
(
instantiatedEditor
);
}
// Check if loading is pending from another openEditor
call
let
pendingEditorLoad
=
this
.
mapEditorLoading
PromiseToEditor
[
position
][
descriptor
.
getId
()];
if
(
pendingEditorLoad
)
{
loadEditorPromise
=
pendingEditorLoad
;
// Return early if editor is being instantiated at the same time from a previous
call
let
pendingEditorInstantiate
=
this
.
mapEditorInstantiation
PromiseToEditor
[
position
][
descriptor
.
getId
()];
if
(
pendingEditorInstantiate
)
{
return
pendingEditorInstantiate
;
}
// Otherwise load
else
{
let
loaded
=
false
;
// Otherwise instantiate
let
progressService
=
new
WorkbenchProgressService
(
this
.
eventService
,
this
.
sideBySideControl
.
getProgressBar
(
position
),
descriptor
.
getId
(),
true
);
let
editorInstantiationService
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
([
IProgressService
,
progressService
]));
let
loaded
=
false
;
load
EditorPromise
=
editorInstantiationService
.
createInstance
(
descriptor
).
then
((
editor
:
BaseEditor
)
=>
{
let
instantiate
EditorPromise
=
editorInstantiationService
.
createInstance
(
descriptor
).
then
((
editor
:
BaseEditor
)
=>
{
loaded
=
true
;
this
.
instantiatedEditors
[
position
].
push
(
editor
);
delete
this
.
mapEditorLoading
PromiseToEditor
[
position
][
descriptor
.
getId
()];
delete
this
.
mapEditorInstantiation
PromiseToEditor
[
position
][
descriptor
.
getId
()];
return
editor
;
},
(
error
)
=>
{
loaded
=
true
;
delete
this
.
mapEditorLoading
PromiseToEditor
[
position
][
descriptor
.
getId
()];
delete
this
.
mapEditorInstantiation
PromiseToEditor
[
position
][
descriptor
.
getId
()];
return
TPromise
.
wrapError
(
error
);
});
if
(
!
loaded
)
{
this
.
mapEditorLoadingPromiseToEditor
[
position
][
descriptor
.
getId
()]
=
loadEditorPromise
;
}
}
}
else
{
loadEditorPromise
=
TPromise
.
as
(
instantiatedEditor
);
this
.
mapEditorInstantiationPromiseToEditor
[
position
][
descriptor
.
getId
()]
=
instantiateEditorPromise
;
}
return
load
EditorPromise
;
return
instantiate
EditorPromise
;
}
private
doSetInput
(
editor
:
BaseEditor
,
input
:
EditorInput
,
options
:
EditorOptions
,
position
:
Position
,
monitor
:
ProgressMonitor
):
TPromise
<
BaseEditor
>
{
...
...
@@ -627,7 +625,7 @@ export class EditorPart extends Part implements IEditorPart {
arrays
.
move
(
this
.
visibleEditors
,
from
,
to
);
arrays
.
move
(
this
.
visibleEditorListeners
,
from
,
to
);
arrays
.
move
(
this
.
editorOpenToken
,
from
,
to
);
arrays
.
move
(
this
.
mapEditor
Loading
PromiseToEditor
,
from
,
to
);
arrays
.
move
(
this
.
mapEditor
Instantiation
PromiseToEditor
,
from
,
to
);
arrays
.
move
(
this
.
mapEditorCreationPromiseToEditor
,
from
,
to
);
arrays
.
move
(
this
.
instantiatedEditors
,
from
,
to
);
arrays
.
move
(
this
.
mapEditorToEditorContainers
,
from
,
to
);
...
...
@@ -1031,7 +1029,7 @@ export class EditorPart extends Part implements IEditorPart {
this
.
doRochade
(
this
.
visibleInputListeners
,
from
,
to
,
null
);
this
.
doRochade
(
this
.
visibleEditors
,
from
,
to
,
null
);
this
.
doRochade
(
this
.
editorOpenToken
,
from
,
to
,
null
);
this
.
doRochade
(
this
.
mapEditor
Loading
PromiseToEditor
,
from
,
to
,
Object
.
create
(
null
));
this
.
doRochade
(
this
.
mapEditor
Instantiation
PromiseToEditor
,
from
,
to
,
Object
.
create
(
null
));
this
.
doRochade
(
this
.
mapEditorCreationPromiseToEditor
,
from
,
to
,
Object
.
create
(
null
));
this
.
doRochade
(
this
.
visibleEditorListeners
,
from
,
to
,
[]);
this
.
doRochade
(
this
.
instantiatedEditors
,
from
,
to
,
[]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录