Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6921a69d
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,发现更多精彩内容 >>
提交
6921a69d
编写于
5月 10, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix npe with actions lookup
上级
178e6335
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
115 addition
and
113 deletion
+115
-113
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+114
-112
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
...workbench/browser/parts/editor/sideBySideEditorControl.ts
+1
-1
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
6921a69d
...
...
@@ -109,38 +109,6 @@ export class EditorPart extends Part implements IEditorPart {
this
.
stacksModel
=
this
.
instantiationService
.
createInstance
(
EditorStacksModel
);
}
public
getStacksModel
():
EditorStacksModel
{
return
this
.
stacksModel
;
}
public
getActiveEditorInput
():
EditorInput
{
if
(
!
this
.
sideBySideControl
)
{
return
null
;
// too early
}
let
lastActiveEditor
=
this
.
sideBySideControl
.
getActiveEditor
();
return
lastActiveEditor
?
lastActiveEditor
.
input
:
null
;
}
public
getActiveEditor
():
BaseEditor
{
if
(
!
this
.
sideBySideControl
)
{
return
null
;
// too early
}
return
this
.
sideBySideControl
.
getActiveEditor
();
}
public
getVisibleEditors
():
BaseEditor
[]
{
return
this
.
visibleEditors
?
this
.
visibleEditors
.
filter
((
editor
)
=>
!!
editor
)
:
[];
}
public
setEditors
(
inputs
:
EditorInput
[],
options
?:
EditorOptions
[]):
TPromise
<
BaseEditor
[]
>
{
return
this
.
closeEditors
().
then
(()
=>
{
return
this
.
restoreEditorState
(
inputs
,
options
);
});
}
public
openEditor
(
input
?:
EditorInput
,
options
?:
EditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
BaseEditor
>
;
public
openEditor
(
input
?:
EditorInput
,
options
?:
EditorOptions
,
position
?:
Position
,
widthRatios
?:
number
[]):
TPromise
<
BaseEditor
>
;
public
openEditor
(
input
?:
EditorInput
,
options
?:
EditorOptions
,
arg3
?:
any
,
widthRatios
?:
number
[]):
TPromise
<
BaseEditor
>
{
...
...
@@ -199,55 +167,22 @@ export class EditorPart extends Part implements IEditorPart {
this
.
visibleInputListeners
[
position
]
=
null
;
}
// Close editor when input provided and input gets disposed
if
(
input
)
{
this
.
visibleInputListeners
[
position
]
=
input
.
addListener
(
EventType
.
DISPOSE
,
()
=>
{
// Keep the inputs to close. We use this to support multiple inputs closing
// right after each other and this helps avoid layout issues with the delayed
// timeout based closing below
if
(
input
===
this
.
visibleInputs
[
position
])
{
this
.
pendingEditorInputsToClose
.
push
(
input
);
this
.
startDelayedCloseEditorsFromInputDispose
();
}
});
}
// Close any opened editor at position if input is null
if
(
input
===
null
)
{
if
(
this
.
visibleEditors
[
position
])
{
// Reset counter
this
.
editorSetInputErrorCounter
[
position
]
=
0
;
// Emit Input-Changing Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
null
,
null
,
null
,
null
,
position
));
// Hide Editor
return
this
.
hideEditor
(
this
.
visibleEditors
[
position
],
position
,
true
).
then
(()
=>
{
// Emit Input-Changed Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
null
,
null
,
null
,
null
,
position
));
// Focus next editor if there is still an active one left
let
currentActiveEditor
=
this
.
sideBySideControl
.
getActiveEditor
();
if
(
currentActiveEditor
)
{
return
this
.
openEditor
(
currentActiveEditor
.
input
,
null
,
currentActiveEditor
.
position
).
then
(()
=>
{
// Explicitly trigger the focus changed handler because the side by side control will not trigger it unless
// the user is actively changing focus with the mouse from left to right.
this
.
onEditorFocusChanged
();
return
currentActiveEditor
;
});
}
if
(
!
input
)
{
return
this
.
doCloseEditor
(
input
,
position
);
}
return
TPromise
.
as
<
BaseEditor
>
(
null
);
});
// Close editor when input provided and input gets disposed
this
.
visibleInputListeners
[
position
]
=
input
.
addListener
(
EventType
.
DISPOSE
,
()
=>
{
// Keep the inputs to close. We use this to support multiple inputs closing
// right after each other and this helps avoid layout issues with the delayed
// timeout based closing below
if
(
input
===
this
.
visibleInputs
[
position
])
{
this
.
pendingEditorInputsToClose
.
push
(
input
);
this
.
startDelayedCloseEditorsFromInputDispose
();
}
return
TPromise
.
as
<
BaseEditor
>
(
null
);
}
});
// Lookup Editor and Assert
let
editorDescriptor
=
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
getEditor
(
input
);
...
...
@@ -425,6 +360,41 @@ export class EditorPart extends Part implements IEditorPart {
});
}
private
doCloseEditor
(
input
:
EditorInput
,
position
:
Position
):
TPromise
<
BaseEditor
>
{
if
(
this
.
visibleEditors
[
position
])
{
// Reset counter
this
.
editorSetInputErrorCounter
[
position
]
=
0
;
// Emit Input-Changing Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
null
,
null
,
null
,
null
,
position
));
// Hide Editor
return
this
.
hideEditor
(
this
.
visibleEditors
[
position
],
position
,
true
).
then
(()
=>
{
// Emit Input-Changed Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
null
,
null
,
null
,
null
,
position
));
// Focus next editor if there is still an active one left
let
currentActiveEditor
=
this
.
sideBySideControl
.
getActiveEditor
();
if
(
currentActiveEditor
)
{
return
this
.
openEditor
(
currentActiveEditor
.
input
,
null
,
currentActiveEditor
.
position
).
then
(()
=>
{
// Explicitly trigger the focus changed handler because the side by side control will not trigger it unless
// the user is actively changing focus with the mouse from left to right.
this
.
onEditorFocusChanged
();
return
currentActiveEditor
;
});
}
return
TPromise
.
as
<
BaseEditor
>
(
null
);
});
}
return
TPromise
.
as
<
BaseEditor
>
(
null
);
}
private
startDelayedCloseEditorsFromInputDispose
():
void
{
// To prevent race conditions, we call the close in a timeout because it can well be
...
...
@@ -586,11 +556,11 @@ 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
.
mapEditorLoadingPromiseToEditor
,
from
,
to
,
{}
);
this
.
doRochade
(
this
.
mapEditorCreationPromiseToEditor
,
from
,
to
,
{}
);
this
.
doRochade
(
this
.
mapEditorLoadingPromiseToEditor
,
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
,
[]);
this
.
doRochade
(
this
.
mapEditorToEditorContainers
,
from
,
to
,
{}
);
this
.
doRochade
(
this
.
mapEditorToEditorContainers
,
from
,
to
,
Object
.
create
(
null
)
);
}
}
...
...
@@ -599,37 +569,6 @@ export class EditorPart extends Part implements IEditorPart {
array
[
from
]
=
empty
;
}
public
moveEditor
(
from
:
Position
,
to
:
Position
):
void
{
if
(
!
this
.
visibleEditors
[
from
]
||
!
this
.
visibleEditors
[
to
]
||
from
===
to
)
{
return
;
// Ignore if we cannot move
}
// Move widgets
this
.
sideBySideControl
.
move
(
from
,
to
);
// Move data structures
arrays
.
move
(
this
.
visibleInputs
,
from
,
to
);
arrays
.
move
(
this
.
visibleInputListeners
,
from
,
to
);
arrays
.
move
(
this
.
visibleEditors
,
from
,
to
);
arrays
.
move
(
this
.
visibleEditorListeners
,
from
,
to
);
arrays
.
move
(
this
.
editorOpenToken
,
from
,
to
);
arrays
.
move
(
this
.
mapEditorLoadingPromiseToEditor
,
from
,
to
);
arrays
.
move
(
this
.
mapEditorCreationPromiseToEditor
,
from
,
to
);
arrays
.
move
(
this
.
instantiatedEditors
,
from
,
to
);
arrays
.
move
(
this
.
mapEditorToEditorContainers
,
from
,
to
);
// Update all title areas
this
.
sideBySideControl
.
updateEditorTitleArea
();
// Restore focus
let
activeEditor
=
this
.
sideBySideControl
.
getActiveEditor
();
this
.
openEditor
(
activeEditor
.
input
,
null
,
activeEditor
.
position
).
done
(
null
,
errors
.
onUnexpectedError
);
}
public
arrangeEditors
(
arrangement
:
EditorArrangement
):
void
{
this
.
sideBySideControl
.
arrangeEditors
(
arrangement
);
}
private
setInput
(
editor
:
BaseEditor
,
input
:
EditorInput
,
options
:
EditorOptions
,
position
:
Position
,
loadingPromise
:
TPromise
<
void
>
):
TPromise
<
BaseEditor
>
{
// Emit Input-/Options-Changed Event as appropiate
...
...
@@ -796,6 +735,69 @@ export class EditorPart extends Part implements IEditorPart {
});
}
public
getStacksModel
():
EditorStacksModel
{
return
this
.
stacksModel
;
}
public
getActiveEditorInput
():
EditorInput
{
if
(
!
this
.
sideBySideControl
)
{
return
null
;
// too early
}
let
lastActiveEditor
=
this
.
sideBySideControl
.
getActiveEditor
();
return
lastActiveEditor
?
lastActiveEditor
.
input
:
null
;
}
public
getActiveEditor
():
BaseEditor
{
if
(
!
this
.
sideBySideControl
)
{
return
null
;
// too early
}
return
this
.
sideBySideControl
.
getActiveEditor
();
}
public
getVisibleEditors
():
BaseEditor
[]
{
return
this
.
visibleEditors
?
this
.
visibleEditors
.
filter
((
editor
)
=>
!!
editor
)
:
[];
}
public
setEditors
(
inputs
:
EditorInput
[],
options
?:
EditorOptions
[]):
TPromise
<
BaseEditor
[]
>
{
return
this
.
closeEditors
().
then
(()
=>
{
return
this
.
restoreEditorState
(
inputs
,
options
);
});
}
public
moveEditor
(
from
:
Position
,
to
:
Position
):
void
{
if
(
!
this
.
visibleEditors
[
from
]
||
!
this
.
visibleEditors
[
to
]
||
from
===
to
)
{
return
;
// Ignore if we cannot move
}
// Move widgets
this
.
sideBySideControl
.
move
(
from
,
to
);
// Move data structures
arrays
.
move
(
this
.
visibleInputs
,
from
,
to
);
arrays
.
move
(
this
.
visibleInputListeners
,
from
,
to
);
arrays
.
move
(
this
.
visibleEditors
,
from
,
to
);
arrays
.
move
(
this
.
visibleEditorListeners
,
from
,
to
);
arrays
.
move
(
this
.
editorOpenToken
,
from
,
to
);
arrays
.
move
(
this
.
mapEditorLoadingPromiseToEditor
,
from
,
to
);
arrays
.
move
(
this
.
mapEditorCreationPromiseToEditor
,
from
,
to
);
arrays
.
move
(
this
.
instantiatedEditors
,
from
,
to
);
arrays
.
move
(
this
.
mapEditorToEditorContainers
,
from
,
to
);
// Update all title areas
this
.
sideBySideControl
.
updateEditorTitleArea
();
// Restore focus
let
activeEditor
=
this
.
sideBySideControl
.
getActiveEditor
();
this
.
openEditor
(
activeEditor
.
input
,
null
,
activeEditor
.
position
).
done
(
null
,
errors
.
onUnexpectedError
);
}
public
arrangeEditors
(
arrangement
:
EditorArrangement
):
void
{
this
.
sideBySideControl
.
arrangeEditors
(
arrangement
);
}
public
createContentArea
(
parent
:
Builder
):
Builder
{
// Content Container
...
...
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
浏览文件 @
6921a69d
...
...
@@ -556,7 +556,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
let
actions
=
this
.
mapActionsToEditors
[
from
];
this
.
mapActionsToEditors
[
to
]
=
actions
;
this
.
mapActionsToEditors
[
from
]
=
null
;
this
.
mapActionsToEditors
[
from
]
=
Object
.
create
(
null
)
;
// Update last active position
if
(
this
.
lastActivePosition
===
from
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录