Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
e2c3e4b5
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e2c3e4b5
编写于
6月 08, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
do not eagerly fill options when opening a side editor
上级
e8ddfed2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
63 deletion
+13
-63
src/vs/workbench/browser/parts/editor/editorActions.ts
src/vs/workbench/browser/parts/editor/editorActions.ts
+12
-3
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+1
-60
未找到文件。
src/vs/workbench/browser/parts/editor/editorActions.ts
浏览文件 @
e2c3e4b5
...
...
@@ -19,6 +19,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
export
class
SplitEditorAction
extends
Action
{
...
...
@@ -47,6 +48,16 @@ export class SplitEditorAction extends Action {
return
TPromise
.
as
(
true
);
}
// Options
let
options
:
EditorOptions
;
if
(
activeEditor
instanceof
BaseTextEditor
)
{
options
=
new
TextEditorOptions
();
(
<
TextEditorOptions
>
options
).
viewState
(
activeEditor
.
getControl
().
saveViewState
());
}
else
{
options
=
new
EditorOptions
();
}
options
.
pinned
=
true
;
// Count editors
let
visibleEditors
=
this
.
editorService
.
getVisibleEditors
();
let
editorCount
=
visibleEditors
.
length
;
...
...
@@ -69,9 +80,7 @@ export class SplitEditorAction extends Action {
// Push the center group to the right to make room for the splitted input
else
if
(
activeEditor
.
position
===
Position
.
LEFT
)
{
let
options
=
new
TextEditorOptions
();
options
.
preserveFocus
=
true
;
options
.
pinned
=
true
;
return
this
.
editorService
.
openEditor
(
activeEditor
.
input
,
options
,
Position
.
RIGHT
).
then
(()
=>
{
this
.
editorGroupService
.
moveGroup
(
Position
.
RIGHT
,
Position
.
CENTER
);
...
...
@@ -82,7 +91,7 @@ export class SplitEditorAction extends Action {
// Only split if we have a target position to split to
if
(
typeof
targetPosition
===
'
number
'
)
{
return
this
.
editorService
.
openEditor
(
activeEditor
.
input
,
EditorOptions
.
create
({
pinned
:
true
})
,
targetPosition
);
return
this
.
editorService
.
openEditor
(
activeEditor
.
input
,
options
,
targetPosition
);
}
return
TPromise
.
as
(
true
);
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
e2c3e4b5
...
...
@@ -15,14 +15,12 @@ import nls = require('vs/nls');
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
arrays
=
require
(
'
vs/base/common/arrays
'
);
import
types
=
require
(
'
vs/base/common/types
'
);
import
{
IEditorViewState
,
IEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
{
Scope
as
MementoScope
}
from
'
vs/workbench/common/memento
'
;
import
{
Scope
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
Part
}
from
'
vs/workbench/browser/part
'
;
import
{
IEditorRegistry
,
Extensions
as
EditorExtensions
,
BaseEditor
,
EditorDescriptor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
EditorInput
,
EditorOptions
,
TextEditorOptions
,
ConfirmResult
,
EditorInputEvent
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
import
{
EditorInput
,
EditorOptions
,
ConfirmResult
,
EditorInputEvent
}
from
'
vs/workbench/common/editor
'
;
import
{
SideBySideEditorControl
,
Rochade
,
ISideBySideEditorControl
,
ProgressState
}
from
'
vs/workbench/browser/parts/editor/sideBySideEditorControl
'
;
import
{
WorkbenchProgressService
}
from
'
vs/workbench/services/progress/browser/progressService
'
;
import
{
GroupArrangement
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
@@ -201,12 +199,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Opened to the side
if
(
position
!==
Position
.
LEFT
)
{
// Log side by side use
this
.
telemetryService
.
publicLog
(
'
workbenchSideEditorOpened
'
,
{
position
:
position
});
// Determine options if the editor opens to the side by looking at same input already opened
options
=
this
.
findSideOptions
(
input
,
options
,
position
);
}
// Open through UI
...
...
@@ -1159,58 +1152,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return
arg1
;
}
private
findSideOptions
(
input
:
EditorInput
,
options
:
EditorOptions
,
position
:
Position
):
EditorOptions
{
if
(
(
this
.
visibleEditors
[
position
]
&&
input
.
matches
(
this
.
visibleEditors
[
position
].
input
))
||
// Return early if the input is already showing at the position
(
options
instanceof
TextEditorOptions
&&
(
<
TextEditorOptions
>
options
).
hasOptionsDefined
())
// Return early if explicit text options are defined
)
{
return
options
;
}
// Otherwise try to copy viewstate over from an existing opened editor with same input
let
viewState
:
IEditorViewState
=
null
;
let
editors
=
this
.
getVisibleEditors
();
for
(
let
i
=
0
;
i
<
editors
.
length
;
i
++
)
{
let
editor
=
editors
[
i
];
if
(
!
(
editor
instanceof
BaseTextEditor
))
{
continue
;
// Only works with text editors
}
// Found a match
if
(
input
.
matches
(
editor
.
input
))
{
let
codeEditor
=
<
IEditor
>
editor
.
getControl
();
viewState
=
<
IEditorViewState
>
codeEditor
.
saveViewState
();
break
;
}
}
// Found view state
if
(
viewState
)
{
let
textEditorOptions
:
TextEditorOptions
=
null
;
// Merge into existing text editor options if given
if
(
options
instanceof
TextEditorOptions
)
{
textEditorOptions
=
<
TextEditorOptions
>
options
;
textEditorOptions
.
viewState
(
viewState
);
return
textEditorOptions
;
}
// Otherwise create new
textEditorOptions
=
new
TextEditorOptions
();
textEditorOptions
.
viewState
(
viewState
);
if
(
options
)
{
textEditorOptions
.
mixin
(
options
);
}
return
textEditorOptions
;
}
return
options
;
}
private
startDelayedCloseEditorsFromInputDispose
():
void
{
// To prevent race conditions, we call the close in a timeout because it can well be
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录