Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
19bba67c
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,发现更多精彩内容 >>
提交
19bba67c
编写于
5月 01, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - add copy editor/group to addView() method
上级
bef10712
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
113 addition
and
23 deletion
+113
-23
src/vs/base/common/map.ts
src/vs/base/common/map.ts
+8
-0
src/vs/workbench/browser/parts/editor2/media/nextTitleControl.css
...orkbench/browser/parts/editor2/media/nextTitleControl.css
+6
-6
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
...vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
+18
-5
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
+27
-9
src/vs/workbench/browser/parts/editor2/nextTitleControl.ts
src/vs/workbench/browser/parts/editor2/nextTitleControl.ts
+15
-2
src/vs/workbench/common/editor/editorStacksModel.ts
src/vs/workbench/common/editor/editorStacksModel.ts
+12
-0
src/vs/workbench/services/editor/common/nextEditorGroupsService.ts
...rkbench/services/editor/common/nextEditorGroupsService.ts
+6
-1
src/vs/workbench/test/browser/parts/editor/editorStacksModel.test.ts
...bench/test/browser/parts/editor/editorStacksModel.test.ts
+21
-0
未找到文件。
src/vs/base/common/map.ts
浏览文件 @
19bba67c
...
...
@@ -420,6 +420,14 @@ export class ResourceMap<T> {
public
keys
():
URI
[]
{
return
keys
(
this
.
map
).
map
(
URI
.
parse
);
}
public
clone
():
ResourceMap
<
T
>
{
const
resourceMap
=
new
ResourceMap
<
T
>
();
resourceMap
.
map
.
forEach
((
value
,
key
)
=>
resourceMap
.
map
.
set
(
key
,
value
));
return
resourceMap
;
}
}
// We should fold BoundedMap and LinkedMap. See https://github.com/Microsoft/vscode/issues/28496
...
...
src/vs/workbench/browser/parts/editor2/media/nextTitleControl.css
浏览文件 @
19bba67c
...
...
@@ -86,20 +86,20 @@
/** TODO@grid revisit the split editor action (vertical-layout/horizontal-layout does not exist anymore) */
.monaco-workbench
>
.part.editor
>
.content
.vertical-layout
.editor-group-container
>
.title
.split-editor
-action
{
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title
.split-editor-right
-action
{
background
:
url('split-editor-vertical.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-workbench
>
.part.editor
>
.content
.vertical-layout
.editor-group-container
>
.title
.split-editor
-action
,
.hc-black
.monaco-workbench
>
.part.editor
>
.content
.vertical-layout
.editor-group-container
>
.title
.split-editor
-action
{
.vs-dark
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title
.split-editor-right
-action
,
.hc-black
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title
.split-editor-right
-action
{
background
:
url('split-editor-vertical-inverse.svg')
center
center
no-repeat
;
}
.monaco-workbench
>
.part.editor
>
.content
.horizontal-layout
.editor-group-container
>
.title
.split-editor
-action
{
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title
.split-editor-down
-action
{
background
:
url('split-editor-horizontal.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-workbench
>
.part.editor
>
.content
.horizontal-layout
.editor-group-container
>
.title
.split-editor
-action
,
.hc-black
.monaco-workbench
>
.part.editor
>
.content
.horizontal-layout
.editor-group-container
>
.title
.split-editor
-action
{
.vs-dark
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title
.split-editor-down
-action
,
.hc-black
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title
.split-editor-down
-action
{
background
:
url('split-editor-horizontal-inverse.svg')
center
center
no-repeat
;
}
\ No newline at end of file
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
浏览文件 @
19bba67c
...
...
@@ -64,7 +64,7 @@ export class NextEditorGroupView extends Themable implements IView, INextEditorG
private
group
:
EditorGroup
;
private
isActive
:
boolean
;
private
dimension
:
Dimension
;
private
_
dimension
:
Dimension
;
private
scopedInstantiationService
:
IInstantiationService
;
private
titleContainer
:
HTMLElement
;
...
...
@@ -78,6 +78,7 @@ export class NextEditorGroupView extends Themable implements IView, INextEditorG
private
progressBar
:
ProgressBar
;
constructor
(
sourceView
:
NextEditorGroupView
,
private
groupsAccessor
:
IGroupsAccessor
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
,
...
...
@@ -87,7 +88,11 @@ export class NextEditorGroupView extends Themable implements IView, INextEditorG
)
{
super
(
themeService
);
this
.
group
=
this
.
_register
(
instantiationService
.
createInstance
(
EditorGroup
,
''
));
if
(
sourceView
)
{
this
.
group
=
this
.
_register
(
sourceView
.
group
.
clone
());
}
else
{
this
.
group
=
this
.
_register
(
instantiationService
.
createInstance
(
EditorGroup
,
''
));
}
this
.
group
.
label
=
`Group <
${
this
.
group
.
id
}
>`
;
this
.
doCreate
();
...
...
@@ -147,6 +152,10 @@ export class NextEditorGroupView extends Themable implements IView, INextEditorG
}
}
get
dimension
():
Dimension
{
return
this
.
_dimension
;
}
setActive
(
isActive
:
boolean
):
void
{
this
.
isActive
=
isActive
;
...
...
@@ -168,6 +177,10 @@ export class NextEditorGroupView extends Themable implements IView, INextEditorG
return
this
.
group
.
count
===
0
;
}
isPinned
(
editor
:
EditorInput
):
boolean
{
return
this
.
group
.
isPinned
(
editor
);
}
//#region INextEditorGroup
get
id
():
GroupIdentifier
{
...
...
@@ -477,7 +490,7 @@ export class NextEditorGroupView extends Themable implements IView, INextEditorG
get
onDidChange
()
{
return
Event
.
None
;
}
layout
(
width
:
number
,
height
:
number
):
void
{
this
.
dimension
=
new
Dimension
(
width
,
height
);
this
.
_
dimension
=
new
Dimension
(
width
,
height
);
// Forward to controls
this
.
doLayoutTitleControl
();
...
...
@@ -486,13 +499,13 @@ export class NextEditorGroupView extends Themable implements IView, INextEditorG
private
doLayoutTitleControl
():
void
{
if
(
this
.
titleAreaControl
)
{
this
.
titleAreaControl
.
layout
(
new
Dimension
(
this
.
dimension
.
width
,
NextEditorGroupView
.
EDITOR_TITLE_HEIGHT
));
this
.
titleAreaControl
.
layout
(
new
Dimension
(
this
.
_
dimension
.
width
,
NextEditorGroupView
.
EDITOR_TITLE_HEIGHT
));
}
}
private
doLayoutEditorControl
():
void
{
if
(
this
.
editorControl
)
{
this
.
editorControl
.
layout
(
new
Dimension
(
this
.
dimension
.
width
,
this
.
dimension
.
height
-
NextEditorGroupView
.
EDITOR_TITLE_HEIGHT
));
this
.
editorControl
.
layout
(
new
Dimension
(
this
.
_dimension
.
width
,
this
.
_
dimension
.
height
-
NextEditorGroupView
.
EDITOR_TITLE_HEIGHT
));
}
}
...
...
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
浏览文件 @
19bba67c
...
...
@@ -12,11 +12,11 @@ import { Part } from 'vs/workbench/browser/part';
import
{
Dimension
,
addClass
,
isAncestor
}
from
'
vs/base/browser/dom
'
;
import
{
Event
,
Emitter
,
once
}
from
'
vs/base/common/event
'
;
import
{
editorBackground
,
contrastBorder
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
INextEditorGroupsService
,
Direction
}
from
'
vs/workbench/services/editor/common/nextEditorGroupsService
'
;
import
{
INextEditorGroupsService
,
Direction
,
IAddGroupOptions
}
from
'
vs/workbench/services/editor/common/nextEditorGroupsService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
SplitGridView
,
Direction
as
GridViewDirection
}
from
'
vs/base/browser/ui/grid/gridview
'
;
import
{
NextEditorGroupView
}
from
'
vs/workbench/browser/parts/editor2/nextEditorGroupView
'
;
import
{
GroupIdentifier
}
from
'
vs/workbench/common/editor
'
;
import
{
GroupIdentifier
,
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
{
EDITOR_GROUP_BORDER
}
from
'
vs/workbench/common/theme
'
;
...
...
@@ -79,16 +79,34 @@ export class NextEditorPart extends Part implements INextEditorGroupsService {
return
groupView
;
}
addGroup
(
fromGroup
:
NextEditorGroupView
|
GroupIdentifier
,
direction
:
Direction
):
NextEditorGroupView
{
const
groupView
=
this
.
doCreateGroupView
()
;
addGroup
(
fromGroup
:
NextEditorGroupView
|
GroupIdentifier
,
direction
:
Direction
,
options
:
IAddGroupOptions
=
Object
.
create
(
null
)
):
NextEditorGroupView
{
const
{
copyGroup
,
copyEditor
}
=
options
;
const
fromGroupView
=
this
.
asGroupView
(
fromGroup
);
const
newGroupView
=
this
.
doCreateGroupView
(
copyGroup
?
fromGroupView
:
void
0
);
// Add to grid widget
this
.
gridWidget
.
splitView
(
this
.
asGroupView
(
fromGroup
)
,
fromGroupView
,
this
.
toGridViewDirection
(
direction
),
groupView
,
direction
===
Direction
.
DOWN
?
this
.
dimension
.
height
/
2
:
this
.
dimension
.
width
/
2
/* TODO@grid what size? */
newGroupView
,
direction
===
Direction
.
DOWN
?
fromGroupView
.
dimension
.
height
/
2
:
fromGroupView
.
dimension
.
width
/
2
/* TODO@grid what size? */
);
return
groupView
;
// Check for options
const
activeEditor
=
fromGroupView
.
activeEditor
;
if
((
copyGroup
||
copyEditor
)
&&
activeEditor
)
{
let
options
:
EditorOptions
;
if
(
copyGroup
)
{
options
=
EditorOptions
.
create
({
pinned
:
fromGroupView
.
isPinned
(
activeEditor
)
});
// copy group preserves all pinned state
}
else
{
options
=
EditorOptions
.
create
({
pinned
:
true
});
// copy of single editor is a sign of importance, so pin it
}
newGroupView
.
openEditor
(
activeEditor
,
options
);
}
return
newGroupView
;
}
removeGroup
(
group
:
NextEditorGroupView
|
GroupIdentifier
):
void
{
...
...
@@ -171,8 +189,8 @@ export class NextEditorPart extends Part implements INextEditorGroupsService {
this
.
_onDidActiveGroupChange
.
fire
(
group
);
}
private
doCreateGroupView
():
NextEditorGroupView
{
const
groupView
=
this
.
instantiationService
.
createInstance
(
NextEditorGroupView
,
{
private
doCreateGroupView
(
sourceView
?:
NextEditorGroupView
):
NextEditorGroupView
{
const
groupView
=
this
.
instantiationService
.
createInstance
(
NextEditorGroupView
,
sourceView
,
{
isOpenedInOtherGroup
:
editor
=>
{
return
this
.
groups
.
some
(
group
=>
group
!==
groupView
&&
group
.
contains
(
editor
));
}
...
...
src/vs/workbench/browser/parts/editor2/nextTitleControl.ts
浏览文件 @
19bba67c
...
...
@@ -37,7 +37,7 @@ import { isDiffEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
Dimension
}
from
'
vs/base/browser/dom
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
INextEditorGroupsService
}
from
'
vs/workbench/services/editor/common/nextEditorGroupsService
'
;
import
{
INextEditorGroupsService
,
Direction
}
from
'
vs/workbench/services/editor/common/nextEditorGroupsService
'
;
export
interface
IToolbarActions
{
primary
:
IAction
[];
...
...
@@ -276,7 +276,20 @@ export abstract class NextTitleControl extends Themable implements INextTitleAre
if
(
isActive
)
{
primaryEditorActions
=
prepareActions
(
editorActions
.
primary
);
if
(
editor
instanceof
EditorInput
&&
editor
.
supportsSplitEditor
())
{
primaryEditorActions
.
push
(
this
.
splitEditorAction
);
// TODO@grid temporary actions to play with
// primaryEditorActions.push(this.splitEditorAction);
primaryEditorActions
.
push
(
new
Action
(
'
split.right
'
,
'
Split Right
'
,
'
split-editor-right-action
'
,
true
,
()
=>
{
this
.
nextEditorGroupsService
.
addGroup
(
this
.
nextEditorGroupsService
.
activeGroup
,
Direction
.
RIGHT
,
{
copyEditor
:
true
});
return
TPromise
.
as
(
true
);
}));
primaryEditorActions
.
push
(
new
Action
(
'
split.down
'
,
'
Split Down
'
,
'
split-editor-down-action
'
,
true
,
()
=>
{
this
.
nextEditorGroupsService
.
addGroup
(
this
.
nextEditorGroupsService
.
activeGroup
,
Direction
.
DOWN
,
{
copyEditor
:
true
});
return
TPromise
.
as
(
true
);
}));
}
}
...
...
src/vs/workbench/common/editor/editorStacksModel.ts
浏览文件 @
19bba67c
...
...
@@ -685,6 +685,18 @@ export class EditorGroup extends Disposable implements IEditorGroup {
this
.
active
=
this
.
mru
[
0
];
this
.
preview
=
this
.
editors
[
data
.
preview
];
}
public
clone
():
EditorGroup
{
const
group
=
this
.
instantiationService
.
createInstance
(
EditorGroup
,
''
);
group
.
editors
=
this
.
editors
.
slice
(
0
);
group
.
mru
=
this
.
mru
.
slice
(
0
);
group
.
mapResourceToEditorCount
=
this
.
mapResourceToEditorCount
.
clone
();
group
.
preview
=
this
.
preview
;
group
.
active
=
this
.
active
;
group
.
editorOpenPositioning
=
this
.
editorOpenPositioning
;
return
group
;
}
}
interface
ISerializedEditorStacksModel
{
...
...
src/vs/workbench/services/editor/common/nextEditorGroupsService.ts
浏览文件 @
19bba67c
...
...
@@ -57,6 +57,11 @@ export interface INextEditorGroup {
pinEditor
(
editor
?:
IEditorInput
):
void
;
}
export
interface
IAddGroupOptions
{
copyGroup
?:
boolean
;
copyEditor
?:
boolean
;
}
export
interface
INextEditorGroupsService
{
_serviceBrand
:
ServiceIdentifier
<
any
>
;
...
...
@@ -71,6 +76,6 @@ export interface INextEditorGroupsService {
setGroupActive
(
group
:
INextEditorGroup
|
GroupIdentifier
):
INextEditorGroup
;
isGroupActive
(
group
:
INextEditorGroup
|
GroupIdentifier
):
boolean
;
addGroup
(
fromGroup
:
INextEditorGroup
|
GroupIdentifier
,
direction
:
Direction
):
INextEditorGroup
;
addGroup
(
fromGroup
:
INextEditorGroup
|
GroupIdentifier
,
direction
:
Direction
,
options
?:
IAddGroupOptions
):
INextEditorGroup
;
removeGroup
(
group
:
INextEditorGroup
|
GroupIdentifier
):
void
;
}
\ No newline at end of file
src/vs/workbench/test/browser/parts/editor/editorStacksModel.test.ts
浏览文件 @
19bba67c
...
...
@@ -1995,4 +1995,25 @@ suite('Editor Stacks Model', () => {
assert
.
equal
(
notfound2
,
null
);
assert
.
equal
(
notfound3
,
null
);
});
test
(
'
Stack - Clone Group
'
,
function
()
{
const
model
=
create
();
const
group
=
model
.
openGroup
(
'
group
'
);
const
input1
=
input
();
const
input2
=
input
();
const
input3
=
input
();
// Pinned and Active
group
.
openEditor
(
input1
,
{
pinned
:
true
,
active
:
true
});
group
.
openEditor
(
input2
,
{
pinned
:
true
,
active
:
true
});
group
.
openEditor
(
input3
,
{
pinned
:
false
,
active
:
true
});
const
clone
=
group
.
clone
();
assert
.
equal
(
clone
.
count
,
3
);
assert
.
equal
(
clone
.
isPinned
(
input1
),
true
);
assert
.
equal
(
clone
.
isPinned
(
input2
),
true
);
assert
.
equal
(
clone
.
isPinned
(
input3
),
false
);
assert
.
equal
(
clone
.
isActive
(
input3
),
true
);
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录