Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5e271907
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,发现更多精彩内容 >>
提交
5e271907
编写于
5月 11, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - allow to get groups in grid order
上级
efd80fa8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
50 addition
and
23 deletion
+50
-23
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
+28
-12
src/vs/workbench/services/editor/browser/nextEditorService.ts
...vs/workbench/services/editor/browser/nextEditorService.ts
+2
-2
src/vs/workbench/services/group/common/nextEditorGroupsService.ts
...orkbench/services/group/common/nextEditorGroupsService.ts
+7
-2
src/vs/workbench/test/browser/parts/editor2/nextEditorPart.test.ts
...rkbench/test/browser/parts/editor2/nextEditorPart.test.ts
+13
-7
未找到文件。
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
浏览文件 @
5e271907
...
...
@@ -11,9 +11,9 @@ import { Part } from 'vs/workbench/browser/part';
import
{
Dimension
,
isAncestor
,
toggleClass
,
addClass
,
clearNode
}
from
'
vs/base/browser/dom
'
;
import
{
Event
,
Emitter
,
once
}
from
'
vs/base/common/event
'
;
import
{
contrastBorder
,
editorBackground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
INextEditorGroupsService
,
GroupDirection
,
IAddGroupOptions
,
GroupsArrangement
,
GroupOrientation
,
IMergeGroupOptions
,
MergeGroupMode
,
ICopyEditorOptions
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
import
{
INextEditorGroupsService
,
GroupDirection
,
IAddGroupOptions
,
GroupsArrangement
,
GroupOrientation
,
IMergeGroupOptions
,
MergeGroupMode
,
ICopyEditorOptions
,
GroupsOrder
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Direction
,
SerializableGrid
,
Sizing
,
ISerializedGrid
,
Orientation
,
ISerializedNode
}
from
'
vs/base/browser/ui/grid/grid
'
;
import
{
Direction
,
SerializableGrid
,
Sizing
,
ISerializedGrid
,
Orientation
,
ISerializedNode
,
GridBranchNode
,
isGridBranchNode
,
GridNode
}
from
'
vs/base/browser/ui/grid/grid
'
;
import
{
GroupIdentifier
,
IWorkbenchEditorConfiguration
}
from
'
vs/workbench/common/editor
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
{
EDITOR_GROUP_BORDER
}
from
'
vs/workbench/common/theme
'
;
...
...
@@ -168,16 +168,32 @@ export class NextEditorPart extends Part implements INextEditorGroupsService, IN
return
this
.
gridWidget
.
orientation
===
Orientation
.
VERTICAL
?
GroupOrientation
.
VERTICAL
:
GroupOrientation
.
HORIZONTAL
;
}
getGroups
(
sortByMostRecentlyActive
?:
boolean
):
INextEditorGroupView
[]
{
if
(
!
sortByMostRecentlyActive
)
{
return
this
.
groups
;
}
getGroups
(
order
?:
GroupsOrder
):
INextEditorGroupView
[]
{
switch
(
order
)
{
case
GroupsOrder
.
MOST_RECENTLY_ACTIVE
:
const
mostRecentActive
=
this
.
mostRecentActiveGroups
.
map
(
groupId
=>
this
.
getGroup
(
groupId
));
// there can be groups that got never active, even though they exist. in this case
// make sure to ust append them at the end so that all groups are returned properly
return
distinct
([...
mostRecentActive
,
...
this
.
groups
]);
case
GroupsOrder
.
GRID_ORDER
:
const
views
:
INextEditorGroupView
[]
=
[];
this
.
fillGridNodes
(
views
,
this
.
gridWidget
.
getViews
());
return
views
;
const
mostRecentActive
=
this
.
mostRecentActiveGroups
.
map
(
groupId
=>
this
.
getGroup
(
groupId
));
default
:
return
this
.
groups
;
}
}
// there can be groups that got never active, even though they exist. in this case
// make sure to ust append them at the end so that all groups are returned properly
return
distinct
([...
mostRecentActive
,
...
this
.
groups
]);
private
fillGridNodes
(
target
:
INextEditorGroupView
[],
node
:
GridBranchNode
<
INextEditorGroupView
>
|
GridNode
<
INextEditorGroupView
>
):
void
{
if
(
isGridBranchNode
(
node
))
{
node
.
children
.
forEach
(
child
=>
this
.
fillGridNodes
(
target
,
child
));
}
else
{
target
.
push
(
node
.
view
);
}
}
getGroup
(
identifier
:
GroupIdentifier
):
INextEditorGroupView
{
...
...
@@ -377,7 +393,7 @@ export class NextEditorPart extends Part implements INextEditorGroupsService, IN
}
private
doRemoveGroupWithEditors
(
groupView
:
INextEditorGroupView
):
void
{
const
mostRecentlyActiveGroups
=
this
.
getGroups
(
true
);
const
mostRecentlyActiveGroups
=
this
.
getGroups
(
GroupsOrder
.
MOST_RECENTLY_ACTIVE
);
let
lastActiveGroup
:
INextEditorGroupView
;
if
(
this
.
_activeGroup
===
groupView
)
{
...
...
@@ -396,7 +412,7 @@ export class NextEditorPart extends Part implements INextEditorGroupsService, IN
// Activate next group if the removed one was active
if
(
this
.
_activeGroup
===
groupView
)
{
const
mostRecentlyActiveGroups
=
this
.
getGroups
(
true
);
const
mostRecentlyActiveGroups
=
this
.
getGroups
(
GroupsOrder
.
MOST_RECENTLY_ACTIVE
);
const
nextActiveGroup
=
mostRecentlyActiveGroups
[
1
];
// [0] will be the current group we are about to dispose
this
.
activateGroup
(
nextActiveGroup
);
}
...
...
src/vs/workbench/services/editor/browser/nextEditorService.ts
浏览文件 @
5e271907
...
...
@@ -24,7 +24,7 @@ import { basename } from 'vs/base/common/paths';
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
INextEditorGroupsService
,
INextEditorGroup
,
GroupDirection
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
import
{
INextEditorGroupsService
,
INextEditorGroup
,
GroupDirection
,
GroupsOrder
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
import
{
INextEditorService
,
IResourceEditor
,
ACTIVE_GROUP_TYPE
,
SIDE_GROUP_TYPE
,
SIDE_GROUP
,
ACTIVE_GROUP
}
from
'
vs/workbench/services/editor/common/nextEditorService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
Disposable
,
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
...
...
@@ -217,7 +217,7 @@ export class NextEditorService extends Disposable implements INextEditorService
// Group: Unspecified without a specific index to open
else
if
(
!
options
||
typeof
options
.
index
!==
'
number
'
)
{
const
groupsByLastActive
=
this
.
nextEditorGroupsService
.
getGroups
(
true
);
const
groupsByLastActive
=
this
.
nextEditorGroupsService
.
getGroups
(
GroupsOrder
.
MOST_RECENTLY_ACTIVE
);
// Respect option to reveal an editor if it is already visible in any group
if
(
options
&&
options
.
revealIfVisible
)
{
...
...
src/vs/workbench/services/group/common/nextEditorGroupsService.ts
浏览文件 @
5e271907
...
...
@@ -73,6 +73,11 @@ export interface IEditorReplacement {
options
?:
IEditorOptions
;
}
export
enum
GroupsOrder
{
MOST_RECENTLY_ACTIVE
,
GRID_ORDER
}
export
interface
INextEditorGroupsService
{
_serviceBrand
:
ServiceIdentifier
<
any
>
;
...
...
@@ -120,9 +125,9 @@ export interface INextEditorGroupsService {
/**
* Get all groups that are currently visible in the editor area optionally
* sorted by being most recent active.
* sorted by being most recent active
or grid order
.
*/
getGroups
(
sortByMostRecentlyActive
?:
boolean
):
ReadonlyArray
<
INextEditorGroup
>
;
getGroups
(
order
?:
GroupsOrder
):
ReadonlyArray
<
INextEditorGroup
>
;
/**
* Allows to convert a group identifier to a group.
...
...
src/vs/workbench/test/browser/parts/editor2/nextEditorPart.test.ts
浏览文件 @
5e271907
...
...
@@ -8,7 +8,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
NextEditorPart
}
from
'
vs/workbench/browser/parts/editor2/nextEditorPart
'
;
import
{
workbenchInstantiationService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
GroupDirection
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
import
{
GroupDirection
,
GroupsOrder
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
import
{
Dimension
}
from
'
vs/base/browser/dom
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
INextEditorPartOptions
}
from
'
vs/workbench/browser/parts/editor2/editor2
'
;
...
...
@@ -121,7 +121,7 @@ suite('Next editor2 part tests', () => {
assert
.
equal
(
rootGroup
,
part
.
getGroup
(
rootGroup
.
id
));
assert
.
ok
(
part
.
activeGroup
===
rootGroup
);
let
mru
=
part
.
getGroups
(
true
);
let
mru
=
part
.
getGroups
(
GroupsOrder
.
MOST_RECENTLY_ACTIVE
);
assert
.
equal
(
mru
.
length
,
1
);
assert
.
equal
(
mru
[
0
],
rootGroup
);
...
...
@@ -132,7 +132,7 @@ suite('Next editor2 part tests', () => {
assert
.
equal
(
part
.
count
,
2
);
assert
.
ok
(
part
.
activeGroup
===
rootGroup
);
mru
=
part
.
getGroups
(
true
);
mru
=
part
.
getGroups
(
GroupsOrder
.
MOST_RECENTLY_ACTIVE
);
assert
.
equal
(
mru
.
length
,
2
);
assert
.
equal
(
mru
[
0
],
rootGroup
);
assert
.
equal
(
mru
[
1
],
rightGroup
);
...
...
@@ -143,7 +143,7 @@ suite('Next editor2 part tests', () => {
assert
.
ok
(
part
.
activeGroup
===
rightGroup
);
assert
.
equal
(
activeGroupChangeCounter
,
1
);
mru
=
part
.
getGroups
(
true
);
mru
=
part
.
getGroups
(
GroupsOrder
.
MOST_RECENTLY_ACTIVE
);
assert
.
equal
(
mru
.
length
,
2
);
assert
.
equal
(
mru
[
0
],
rightGroup
);
assert
.
equal
(
mru
[
1
],
rootGroup
);
...
...
@@ -158,12 +158,18 @@ suite('Next editor2 part tests', () => {
assert
.
ok
(
part
.
activeGroup
===
rightGroup
);
assert
.
ok
(
!
downGroup
.
activeControl
);
mru
=
part
.
getGroups
(
true
);
mru
=
part
.
getGroups
(
GroupsOrder
.
MOST_RECENTLY_ACTIVE
);
assert
.
equal
(
mru
.
length
,
3
);
assert
.
equal
(
mru
[
0
],
rightGroup
);
assert
.
equal
(
mru
[
1
],
rootGroup
);
assert
.
equal
(
mru
[
2
],
downGroup
);
const
gridOrder
=
part
.
getGroups
(
GroupsOrder
.
GRID_ORDER
);
assert
.
equal
(
gridOrder
.
length
,
3
);
assert
.
equal
(
gridOrder
[
0
],
rootGroup
);
assert
.
equal
(
gridOrder
[
1
],
rightGroup
);
assert
.
equal
(
gridOrder
[
2
],
downGroup
);
part
.
moveGroup
(
downGroup
,
rightGroup
,
GroupDirection
.
DOWN
);
assert
.
equal
(
groupMovedCounter
,
1
);
...
...
@@ -174,7 +180,7 @@ suite('Next editor2 part tests', () => {
assert
.
equal
(
part
.
groups
.
length
,
2
);
assert
.
ok
(
part
.
activeGroup
===
rightGroup
);
mru
=
part
.
getGroups
(
true
);
mru
=
part
.
getGroups
(
GroupsOrder
.
MOST_RECENTLY_ACTIVE
);
assert
.
equal
(
mru
.
length
,
2
);
assert
.
equal
(
mru
[
0
],
rightGroup
);
assert
.
equal
(
mru
[
1
],
rootGroup
);
...
...
@@ -198,7 +204,7 @@ suite('Next editor2 part tests', () => {
assert
.
equal
(
part
.
groups
.
length
,
1
);
assert
.
ok
(
part
.
activeGroup
===
rootGroup
);
mru
=
part
.
getGroups
(
true
);
mru
=
part
.
getGroups
(
GroupsOrder
.
MOST_RECENTLY_ACTIVE
);
assert
.
equal
(
mru
.
length
,
1
);
assert
.
equal
(
mru
[
0
],
rootGroup
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录