Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b5d19ccf
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,发现更多精彩内容 >>
提交
b5d19ccf
编写于
5月 11, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more cleanup
上级
63a5a38c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
73 addition
and
54 deletion
+73
-54
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+45
-42
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
...workbench/browser/parts/editor/sideBySideEditorControl.ts
+28
-12
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
b5d19ccf
...
...
@@ -25,7 +25,7 @@ import {EventType as WorkbenchEventType, EditorEvent} from 'vs/workbench/common/
import
{
IEditorRegistry
,
Extensions
as
EditorExtensions
,
BaseEditor
,
EditorDescriptor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
EditorInput
,
EditorOptions
,
TextEditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
import
{
SideBySideEditorControl
,
Rochade
,
ISideBySideEditorControl
}
from
'
vs/workbench/browser/parts/editor/sideBySideEditorControl
'
;
import
{
SideBySideEditorControl
,
Rochade
,
ISideBySideEditorControl
,
ProgressState
}
from
'
vs/workbench/browser/parts/editor/sideBySideEditorControl
'
;
import
{
WorkbenchProgressService
}
from
'
vs/workbench/services/progress/browser/progressService
'
;
import
{
EditorArrangement
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorPart
}
from
'
vs/workbench/services/editor/browser/editorService
'
;
...
...
@@ -212,7 +212,7 @@ export class EditorPart extends Part implements IEditorPart {
const
editorOpenToken
=
this
.
editorOpenToken
[
position
];
const
monitor
=
new
ProgressMonitor
(
editorOpenToken
,
TPromise
.
timeout
(
this
.
partService
.
isCreated
()
?
800
:
3200
/* less ugly initial startup */
).
then
(()
=>
{
if
(
editorOpenToken
===
this
.
editorOpenToken
[
position
])
{
this
.
sideBySideControl
.
getProgressBar
(
position
).
infinite
().
getContainer
().
show
(
);
this
.
sideBySideControl
.
updateProgress
(
position
,
ProgressState
.
INFINITE
);
this
.
sideBySideControl
.
setLoading
(
position
,
input
);
}
}));
...
...
@@ -423,15 +423,14 @@ export class EditorPart extends Part implements IEditorPart {
}
// Progress Done
this
.
sideBySideControl
.
getProgressBar
(
position
).
done
().
getContainer
().
hide
(
);
this
.
sideBySideControl
.
updateProgress
(
position
,
ProgressState
.
DONE
);
// Update Title Area if input changed
if
(
inputChanged
)
{
// Update Title Area if input changed
this
.
sideBySideControl
.
updateEditorTitleArea
();
}
// Emit Input-Changed Event (if input changed)
if
(
inputChanged
)
{
// Emit Input-Changed Event (if input changed)
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
editor
,
editor
.
getId
(),
input
,
options
,
position
));
}
...
...
@@ -439,48 +438,52 @@ export class EditorPart extends Part implements IEditorPart {
// Fullfill promise with Editor that is being used
return
editor
;
},
(
e
:
any
)
=>
{
// Keep counter
this
.
editorSetInputErrorCounter
[
position
]
++
;
},
(
e
:
any
)
=>
this
.
doHandleSetInputError
(
e
,
editor
,
input
,
oldInput
,
options
,
position
,
monitor
));
}
// Stop loading promise if any
monitor
.
cancel
();
private
doHandleSetInputError
(
e
:
Error
|
IMessageWithAction
,
editor
:
BaseEditor
,
input
:
EditorInput
,
oldInput
:
EditorInput
,
options
:
EditorOptions
,
position
:
Position
,
monitor
:
ProgressMonitor
):
void
{
// Report error only if this was not us restoring previous error state
if
(
this
.
partService
.
isCreated
()
&&
!
errors
.
isPromiseCanceledError
(
e
))
{
let
errorMessage
=
nls
.
localize
(
'
editorOpenError
'
,
"
Unable to open '{0}': {1}.
"
,
input
.
getName
(),
errors
.
toErrorMessage
(
e
));
// Keep counter
this
.
editorSetInputErrorCounter
[
position
]
++
;
let
error
:
any
;
if
(
e
&&
(
<
IMessageWithAction
>
e
).
actions
&&
(
<
IMessageWithAction
>
e
).
actions
.
length
)
{
error
=
errors
.
create
(
errorMessage
,
{
actions
:
(
<
IMessageWithAction
>
e
).
actions
});
// Support error actions from thrower
}
else
{
error
=
errorMessage
;
}
// Stop loading promise if any
monitor
.
cancel
();
// Report error only if this was not us restoring previous error state
if
(
this
.
partService
.
isCreated
()
&&
!
errors
.
isPromiseCanceledError
(
e
))
{
let
errorMessage
=
nls
.
localize
(
'
editorOpenError
'
,
"
Unable to open '{0}': {1}.
"
,
input
.
getName
(),
errors
.
toErrorMessage
(
e
));
this
.
messageService
.
show
(
Severity
.
Error
,
types
.
isString
(
error
)
?
new
Error
(
error
)
:
error
);
let
error
:
any
;
if
(
e
&&
(
<
IMessageWithAction
>
e
).
actions
&&
(
<
IMessageWithAction
>
e
).
actions
.
length
)
{
error
=
errors
.
create
(
errorMessage
,
{
actions
:
(
<
IMessageWithAction
>
e
).
actions
});
// Support error actions from thrower
}
else
{
error
=
errorMessage
;
}
this
.
sideBySideControl
.
getProgressBar
(
position
).
done
().
getContainer
().
hide
(
);
this
.
emit
(
WorkbenchEventType
.
EDITOR_SET_INPUT_ERROR
,
new
EditorEvent
(
editor
,
editor
.
getId
(),
input
,
options
,
position
));
this
.
messageService
.
show
(
Severity
.
Error
,
types
.
isString
(
error
)
?
new
Error
(
error
)
:
error
);
}
// Recover from this error by closing the editor if the attempt of setInput failed and we are not having any previous input
if
(
!
oldInput
&&
this
.
visibleInputs
[
position
]
===
input
&&
input
)
{
this
.
openEditor
(
null
,
null
,
position
).
done
(
null
,
errors
.
onUnexpectedError
);
}
this
.
sideBySideControl
.
updateProgress
(
position
,
ProgressState
.
DONE
);
this
.
emit
(
WorkbenchEventType
.
EDITOR_SET_INPUT_ERROR
,
new
EditorEvent
(
editor
,
editor
.
getId
(),
input
,
options
,
position
));
// We need to check our error counter here to prevent reentrant setInput() calls. If the workbench is in error state
// to the disk, opening a file would fail and we would try to open the previous file which would fail too. So we
// stop trying to open a previous file if we detect that we failed more than once already
else
if
(
this
.
editorSetInputErrorCounter
[
position
]
>
1
)
{
this
.
openEditor
(
null
,
null
,
position
).
done
(
null
,
errors
.
onUnexpectedError
);
}
// Recover from this error by closing the editor if the attempt of setInput failed and we are not having any previous input
if
(
!
oldInput
&&
this
.
visibleInputs
[
position
]
===
input
&&
input
)
{
this
.
openEditor
(
null
,
null
,
position
).
done
(
null
,
errors
.
onUnexpectedError
);
}
// Otherwise if we had oldInput, properly restore it so that the active input points to the previous one
else
if
(
oldInput
)
{
this
.
openEditor
(
oldInput
,
null
,
position
).
done
(
null
,
errors
.
onUnexpectedError
);
}
});
// We need to check our error counter here to prevent reentrant setInput() calls. If the workbench is in error state
// to the disk, opening a file would fail and we would try to open the previous file which would fail too. So we
// stop trying to open a previous file if we detect that we failed more than once already
else
if
(
this
.
editorSetInputErrorCounter
[
position
]
>
1
)
{
this
.
openEditor
(
null
,
null
,
position
).
done
(
null
,
errors
.
onUnexpectedError
);
}
// Otherwise if we had oldInput, properly restore it so that the active input points to the previous one
else
if
(
oldInput
)
{
this
.
openEditor
(
oldInput
,
null
,
position
).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
private
doCloseEditor
(
input
:
EditorInput
,
position
:
Position
):
TPromise
<
BaseEditor
>
{
...
...
@@ -525,7 +528,7 @@ export class EditorPart extends Part implements IEditorPart {
let
rochade
=
this
.
sideBySideControl
.
hide
(
editor
,
editorContainer
,
position
,
layoutAndRochade
);
// Clear any running Progress
this
.
sideBySideControl
.
getProgressBar
(
position
).
stop
().
getContainer
().
hide
(
);
this
.
sideBySideControl
.
updateProgress
(
position
,
ProgressState
.
STOP
);
// Clear Listeners
while
(
this
.
visibleEditorListeners
[
position
].
length
)
{
...
...
@@ -672,7 +675,7 @@ export class EditorPart extends Part implements IEditorPart {
if
(
editorState
&&
editorState
.
editors
)
{
// Find inputs to restore
let
registry
=
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)
);
let
registry
=
Registry
.
as
<
IEditorRegistry
>
(
EditorExtensions
.
Editors
);
let
inputs
:
EditorInput
[]
=
[];
widthRatios
=
editorState
.
widthRatio
;
...
...
@@ -791,7 +794,7 @@ export class EditorPart extends Part implements IEditorPart {
}
private
saveEditorState
():
void
{
let
registry
=
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)
);
let
registry
=
Registry
.
as
<
IEditorRegistry
>
(
EditorExtensions
.
Editors
);
let
editors
=
this
.
getVisibleEditors
();
let
activeEditor
=
this
.
getActiveEditor
();
...
...
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
浏览文件 @
b5d19ccf
...
...
@@ -44,6 +44,12 @@ export enum Rochade {
CENTER_AND_RIGHT_TO_LEFT
}
export
enum
ProgressState
{
INFINITE
,
DONE
,
STOP
}
interface
IEditorActions
{
primary
:
IAction
[];
secondary
:
IAction
[];
...
...
@@ -64,8 +70,12 @@ export interface ISideBySideEditorControl {
move
(
from
:
Position
,
to
:
Position
):
void
;
isDragging
():
boolean
;
setLoading
(
position
:
Position
,
input
:
EditorInput
):
void
;
getProgressBar
(
position
:
Position
):
ProgressBar
;
updateProgress
(
position
:
Position
,
state
:
ProgressState
):
void
;
layout
(
dimension
:
Dimension
):
void
;
layout
(
position
:
Position
):
void
;
...
...
@@ -1212,7 +1222,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
return
actionItem
;
}
p
ublic
setTitle
(
position
:
Position
,
input
:
EditorInput
,
primaryActions
:
IAction
[],
secondaryActions
:
IAction
[],
isActive
:
boolean
):
void
{
p
rivate
setTitle
(
position
:
Position
,
input
:
EditorInput
,
primaryActions
:
IAction
[],
secondaryActions
:
IAction
[],
isActive
:
boolean
):
void
{
// Activity class
if
(
isActive
)
{
...
...
@@ -1238,11 +1248,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this
.
titleDescription
[
position
].
title
(
verboseDescription
);
// Editor Input State Description
if
(
input
)
{
this
.
setEditorInputStateIndicator
(
input
,
input
.
getStatus
(),
position
);
}
else
{
this
.
setEditorInputStateIndicator
(
null
,
null
,
null
);
}
this
.
setEditorInputStateIndicator
(
input
,
input
.
getStatus
(),
position
);
// Support split editor action if visible editor count is < 3 and editor supports it
if
(
isActive
&&
this
.
getVisibleEditorCount
()
<
3
&&
this
.
lastActiveEditor
.
supportsSplitEditor
())
{
...
...
@@ -1253,9 +1259,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this
.
editorActionsToolbar
[
position
].
setActions
(
primaryActions
,
secondaryActions
)();
// Add a close action
if
(
input
)
{
this
.
editorActionsToolbar
[
position
].
addPrimaryAction
(
this
.
closeEditorAction
[
position
])();
}
this
.
editorActionsToolbar
[
position
].
addPrimaryAction
(
this
.
closeEditorAction
[
position
])();
}
public
setLoading
(
position
:
Position
,
input
:
EditorInput
):
void
{
...
...
@@ -1268,9 +1272,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this
.
editorActionsToolbar
[
position
].
setActions
([],
[])();
// Add a close action
if
(
input
)
{
this
.
editorActionsToolbar
[
position
].
addPrimaryAction
(
this
.
closeEditorAction
[
position
])();
}
this
.
editorActionsToolbar
[
position
].
addPrimaryAction
(
this
.
closeEditorAction
[
position
])();
}
public
clearTitle
(
position
:
Position
):
void
{
...
...
@@ -1597,6 +1599,20 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
return
this
.
progressBar
[
position
];
}
public
updateProgress
(
position
:
Position
,
state
:
ProgressState
):
void
{
switch
(
state
)
{
case
ProgressState
.
INFINITE
:
this
.
progressBar
[
position
].
infinite
().
getContainer
().
show
();
break
;
case
ProgressState
.
DONE
:
this
.
progressBar
[
position
].
done
().
getContainer
().
hide
();
break
;
case
ProgressState
.
STOP
:
this
.
progressBar
[
position
].
stop
().
getContainer
().
hide
();
break
;
}
}
public
dispose
():
void
{
// Positions
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录