Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
232c5b56
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,发现更多精彩内容 >>
提交
232c5b56
编写于
5月 10, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more cleanup
上级
52540495
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
46 deletion
+34
-46
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+34
-46
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
232c5b56
...
...
@@ -14,7 +14,6 @@ import {EventType} from 'vs/base/common/events';
import
{
Dimension
,
Builder
,
$
}
from
'
vs/base/browser/builder
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
assert
=
require
(
'
vs/base/common/assert
'
);
import
arrays
=
require
(
'
vs/base/common/arrays
'
);
import
types
=
require
(
'
vs/base/common/types
'
);
import
{
IEditorViewState
,
IEditor
}
from
'
vs/editor/common/editorCommon
'
;
...
...
@@ -57,7 +56,8 @@ interface IEditorState {
/**
* TODO@stacks
* - need to listen to any input dispose that is opened in a stack not just the visible one to close a non active editor
* -
* -> maybe just hook up a listener to the model.close event and let the model listen on dispose? this would also nicely
* -> cover the unpin() case
*/
/**
...
...
@@ -164,6 +164,14 @@ export class EditorPart extends Part implements IEditorPart {
}
private
doOpenEditor
(
input
:
EditorInput
,
options
:
EditorOptions
,
position
:
Position
,
widthRatios
:
number
[]):
TPromise
<
BaseEditor
>
{
// We need an editor descriptor for the input
let
editorDescriptor
=
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
getEditor
(
input
);
if
(
!
editorDescriptor
)
{
return
TPromise
.
wrapError
(
new
Error
(
strings
.
format
(
'
Can not find a registered editor for the input {0}
'
,
input
)));
}
// Opened to the side
if
(
position
!==
Position
.
LEFT
)
{
// Log side by side use
...
...
@@ -197,32 +205,29 @@ export class EditorPart extends Part implements IEditorPart {
}
});
// Lookup Editor and Assert
let
editorDescriptor
=
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
getEditor
(
input
);
assert
.
ok
(
editorDescriptor
,
strings
.
format
(
'
Can not find a registered editor for the input {0}
'
,
input
));
// Handle Active Editor showing
let
activeEditorHidePromise
:
TPromise
<
BaseEditor
>
;
if
(
this
.
visibleEditors
[
position
])
{
// Show editor
return
this
.
doShowEditor
(
editorDescriptor
,
input
,
options
,
position
,
widthRatios
,
loadingPromise
,
editorOpenToken
).
then
(
editor
=>
{
if
(
!
editor
)
{
return
TPromise
.
as
<
BaseEditor
>
(
null
);
// canceled or other error
}
// Editor can handle Input
if
(
editorDescriptor
.
describes
(
this
.
visibleEditors
[
position
]))
{
// Set input to editor
this
.
setInput
(
editor
,
input
,
options
,
position
,
loadingPromise
);
});
}
// If the editor is currently being created, join this process to avoid issues
let
pendingEditorCreationPromise
=
this
.
mapEditorCreationPromiseToEditor
[
position
][
editorDescriptor
.
getId
()];
if
(
!
pendingEditorCreationPromise
)
{
pendingEditorCreationPromise
=
TPromise
.
as
(
null
);
}
private
doShowEditor
(
editorDescriptor
:
EditorDescriptor
,
input
:
EditorInput
,
options
:
EditorOptions
,
position
:
Position
,
widthRatios
:
number
[],
loadingPromise
:
TPromise
<
void
>
,
editorOpenToken
:
number
):
TPromise
<
BaseEditor
>
{
return
pendingEditorCreationPromise
.
then
(()
=>
{
return
this
.
setInput
(
this
.
visibleEditors
[
position
],
input
,
options
,
position
,
loadingPromise
);
}
);
}
// Return early if the currently visible editor can handle the input
if
(
this
.
visibleEditors
[
position
]
&&
editorDescriptor
.
describes
(
this
.
visibleEditors
[
position
]))
{
return
this
.
mapEditorCreationPromiseToEditor
[
position
][
editorDescriptor
.
getId
()]
||
TPromise
.
as
(
this
.
visibleEditors
[
position
]
);
}
// Editor can not handle Input (Close this Editor)
activeEditorHidePromise
=
this
.
hideEditor
(
this
.
visibleEditors
[
position
],
position
,
false
);
let
activeEditorHidePromise
:
TPromise
<
BaseEditor
>
;
if
(
this
.
visibleEditors
[
position
])
{
activeEditorHidePromise
=
this
.
hideEditor
(
this
.
visibleEditors
[
position
],
position
,
false
);
// Editor can not handle Input (Close this Editor)
}
else
{
activeEditorHidePromise
=
TPromise
.
as
(
null
);
activeEditorHidePromise
=
TPromise
.
as
(
null
);
// Editor needs to be created first
}
return
activeEditorHidePromise
.
then
(()
=>
{
...
...
@@ -246,7 +251,7 @@ export class EditorPart extends Part implements IEditorPart {
}
// Create or get editor from cache
let
editor
=
this
.
getEditorFromCache
(
editorDescriptor
,
position
)
;
let
editor
=
this
.
instantiatedEditors
[
position
].
filter
(
e
=>
editorDescriptor
.
describes
(
e
))[
0
]
||
null
;
let
loadOrGetEditorPromise
:
TPromise
<
BaseEditor
>
;
if
(
editor
===
null
)
{
...
...
@@ -259,7 +264,10 @@ export class EditorPart extends Part implements IEditorPart {
// Otherwise load
else
{
let
loaded
=
false
;
loadOrGetEditorPromise
=
this
.
createEditor
(
editorDescriptor
,
newlyCreatedEditorContainerBuilder
.
getHTMLElement
(),
position
).
then
((
editor
)
=>
{
let
progressService
=
new
WorkbenchProgressService
(
this
.
eventService
,
this
.
sideBySideControl
.
getProgressBar
(
position
),
editorDescriptor
.
getId
(),
true
);
let
editorInstantiationService
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
([
IProgressService
,
progressService
]));
loadOrGetEditorPromise
=
editorInstantiationService
.
createInstance
(
editorDescriptor
).
then
((
editor
:
BaseEditor
)
=>
{
loaded
=
true
;
this
.
instantiatedEditors
[
position
].
push
(
editor
);
delete
this
.
mapEditorLoadingPromiseToEditor
[
position
][
editorDescriptor
.
getId
()];
...
...
@@ -357,8 +365,7 @@ export class EditorPart extends Part implements IEditorPart {
timerEvent
.
stop
();
// Set Input
return
this
.
setInput
(
editor
,
input
,
options
,
position
,
loadingPromise
);
return
editor
;
});
},
(
e
:
any
)
=>
this
.
messageService
.
show
(
Severity
.
Error
,
types
.
isString
(
e
)
?
new
Error
(
e
)
:
e
));
});
...
...
@@ -551,25 +558,6 @@ export class EditorPart extends Part implements IEditorPart {
});
}
private
getEditorFromCache
(
editorDescriptor
:
EditorDescriptor
,
position
:
Position
):
BaseEditor
{
// Check for existing instantiated editor
for
(
let
i
=
0
;
i
<
this
.
instantiatedEditors
[
position
].
length
;
i
++
)
{
if
(
editorDescriptor
.
describes
(
this
.
instantiatedEditors
[
position
][
i
]))
{
return
this
.
instantiatedEditors
[
position
][
i
];
}
}
return
null
;
}
private
createEditor
(
editorDescriptor
:
EditorDescriptor
,
editorDomNode
:
HTMLElement
,
position
:
Position
):
TPromise
<
BaseEditor
>
{
let
progressService
=
new
WorkbenchProgressService
(
this
.
eventService
,
this
.
sideBySideControl
.
getProgressBar
(
position
),
editorDescriptor
.
getId
(),
true
);
let
editorInstantiationService
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
([
IProgressService
,
progressService
]));
return
editorInstantiationService
.
createInstance
(
editorDescriptor
);
}
private
hideEditor
(
editor
:
BaseEditor
,
position
:
Position
,
layoutAndRochade
:
boolean
):
TPromise
<
BaseEditor
>
{
let
editorContainer
=
this
.
mapEditorToEditorContainers
[
position
][
editor
.
getId
()];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录