Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
70c34cd7
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,发现更多精彩内容 >>
提交
70c34cd7
编写于
5月 02, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - find group based on openEditor() configuration
上级
d7162090
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
76 addition
and
78 deletion
+76
-78
src/vs/workbench/browser/parts/editor2/nextEditorControl.ts
src/vs/workbench/browser/parts/editor2/nextEditorControl.ts
+3
-0
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
...vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
+8
-0
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
+18
-2
src/vs/workbench/services/editor/browser/nextEditorService.ts
...vs/workbench/services/editor/browser/nextEditorService.ts
+38
-75
src/vs/workbench/services/editor/common/nextEditorGroupsService.ts
...rkbench/services/editor/common/nextEditorGroupsService.ts
+7
-0
src/vs/workbench/services/editor/common/nextEditorService.ts
src/vs/workbench/services/editor/common/nextEditorService.ts
+2
-1
未找到文件。
src/vs/workbench/browser/parts/editor2/nextEditorControl.ts
浏览文件 @
70c34cd7
...
...
@@ -117,6 +117,9 @@ export class NextEditorControl extends Disposable {
}
private
doSetInput
(
control
:
BaseEditor
,
editor
:
EditorInput
,
options
:
EditorOptions
):
Thenable
<
void
>
{
// Show progress while setting input after a certain timeout. If the workbench is opening
// be more relaxed about progress showing by increasing the delay a little bit to reduce flicker.
const
operationId
=
this
.
editorOperation
.
start
(
this
.
partService
.
isCreated
()
?
800
:
3200
);
// Call into editor control
...
...
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
浏览文件 @
70c34cd7
...
...
@@ -462,6 +462,14 @@ export class NextEditorGroupView extends Themable implements IView, INextEditorG
//#endregion
//#region isOpen()
isOpened
(
editor
:
EditorInput
):
boolean
{
return
this
.
group
.
contains
(
editor
);
}
//#endregion
//#region moveEditor()
moveEditor
(
editor
:
EditorInput
,
target
:
NextEditorGroupView
,
options
?:
IMoveEditorOptions
):
void
{
...
...
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
浏览文件 @
70c34cd7
...
...
@@ -19,6 +19,7 @@ import { NextEditorGroupView, IGroupsAccessor } from 'vs/workbench/browser/parts
import
{
GroupIdentifier
,
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
{
EDITOR_GROUP_BORDER
}
from
'
vs/workbench/common/theme
'
;
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
// TODO@grid provide DND support of groups/editors:
// - editor: move/copy to existing group, move/copy to new split group (up, down, left, right)
...
...
@@ -73,6 +74,18 @@ export class NextEditorPart extends Part implements INextEditorGroupsService {
return
values
(
this
.
groupViews
);
}
getGroups
(
sortByMostRecentlyActive
?:
boolean
):
NextEditorGroupView
[]
{
if
(
!
sortByMostRecentlyActive
)
{
return
this
.
groups
;
}
const
mostRecentActive
=
this
.
mostRecentActive
.
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
]);
}
getGroup
(
identifier
:
GroupIdentifier
):
NextEditorGroupView
{
return
this
.
groupViews
.
get
(
identifier
);
}
...
...
@@ -148,7 +161,7 @@ export class NextEditorPart extends Part implements INextEditorGroupsService {
// Activate next group if the removed one was active
if
(
!
this
.
_activeGroup
)
{
const
nextActiveGroup
=
this
.
asGroupView
(
this
.
mostRecentActive
[
this
.
mostRecentActive
.
length
-
1
]);
const
nextActiveGroup
=
this
.
asGroupView
(
this
.
mostRecentActive
[
0
]);
this
.
activateGroup
(
nextActiveGroup
);
// Restore focus if we had it previously
...
...
@@ -218,12 +231,15 @@ export class NextEditorPart extends Part implements INextEditorGroupsService {
private
doUpdateMostRecentActive
(
group
:
NextEditorGroupView
,
makeMostRecentlyActive
?:
boolean
):
void
{
const
index
=
this
.
mostRecentActive
.
indexOf
(
group
.
id
);
// Remove from MRU list
if
(
index
!==
-
1
)
{
this
.
mostRecentActive
.
splice
(
index
,
1
);
}
// Add to front as needed
if
(
makeMostRecentlyActive
)
{
this
.
mostRecentActive
.
push
(
group
.
id
);
this
.
mostRecentActive
.
unshift
(
group
.
id
);
}
}
...
...
src/vs/workbench/services/editor/browser/nextEditorService.ts
浏览文件 @
70c34cd7
...
...
@@ -24,8 +24,9 @@ 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
}
from
'
vs/workbench/services/editor/common/nextEditorGroupsService
'
;
import
{
INextEditorService
,
IResourceEditor
,
SIDE_BY_SIDE
}
from
'
vs/workbench/services/editor/common/nextEditorService
'
;
import
{
INextEditorGroupsService
,
INextEditorGroup
,
Direction
}
from
'
vs/workbench/services/editor/common/nextEditorGroupsService
'
;
import
{
INextEditorService
,
IResourceEditor
,
SIDE_BY_SIDE
,
SIDE_BY_SIDE_VALUE
}
from
'
vs/workbench/services/editor/common/nextEditorService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
type
ICachedEditorInput
=
ResourceEditorInput
|
IFileEditorInput
|
DataUriEditorInput
;
...
...
@@ -43,7 +44,8 @@ export class NextEditorService implements INextEditorService {
@
IWorkspaceContextService
private
workspaceContextService
:
IWorkspaceContextService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IFileService
private
fileService
:
IFileService
@
IFileService
private
fileService
:
IFileService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
)
{
this
.
fileInputFactory
=
Registry
.
as
<
IEditorInputFactoryRegistry
>
(
EditorExtensions
.
EditorInputFactories
).
getFileInputFactory
();
}
...
...
@@ -79,14 +81,44 @@ export class NextEditorService implements INextEditorService {
private
doOpenEditor
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
group
?:
GroupIdentifier
|
SIDE_BY_SIDE
):
Thenable
<
IEditor
>
{
let
targetGroup
:
INextEditorGroup
;
if
(
group
===
-
1
)
{
group
=
void
0
;
// TODO@grid find correct side group based on active group
// Group: Side by Side
if
(
group
===
SIDE_BY_SIDE_VALUE
)
{
targetGroup
=
this
.
nextEditorGroupsService
.
addGroup
(
this
.
nextEditorGroupsService
.
activeGroup
,
Direction
.
RIGHT
);
}
// Group: Specific Group
if
(
typeof
group
===
'
number
'
)
{
targetGroup
=
this
.
nextEditorGroupsService
.
getGroup
(
group
);
}
// Group: Unspecified without a specific index to open
else
if
(
!
options
||
typeof
options
.
index
!==
'
number
'
)
{
const
groupsByLastActive
=
this
.
nextEditorGroupsService
.
getGroups
(
true
);
// Respect option to reveal an editor if it is already visible in any group
if
(
options
&&
options
.
revealIfVisible
)
{
for
(
let
i
=
0
;
i
<
groupsByLastActive
.
length
;
i
++
)
{
const
group
=
groupsByLastActive
[
i
];
if
(
input
.
matches
(
group
.
activeEditor
))
{
targetGroup
=
group
;
break
;
}
}
}
// Respect option to reveal an editor if it is open (not necessarily visible)
if
((
options
&&
options
.
revealIfOpened
)
||
this
.
configurationService
.
getValue
<
boolean
>
(
'
workbench.editor.revealIfOpen
'
))
{
for
(
let
i
=
0
;
i
<
groupsByLastActive
.
length
;
i
++
)
{
const
group
=
groupsByLastActive
[
i
];
if
(
group
.
isOpened
(
input
))
{
targetGroup
=
group
;
break
;
}
}
}
}
// Fallback to active group if target not valid
if
(
!
targetGroup
)
{
targetGroup
=
this
.
nextEditorGroupsService
.
activeGroup
;
}
...
...
@@ -212,73 +244,4 @@ export class NextEditorService implements INextEditorService {
// Otherwise: for diff labels prefer to see the path as part of the label
return
getPathLabel
(
res
.
fsPath
,
context
,
environment
);
}
}
//#region TODO@grid adopt legacy code to find a position based on options
// private findPosition(input: EditorInput, options ?: EditorOptions, sideBySide ?: boolean, ratio ?: number[]): Position;
// private findPosition(input: EditorInput, options ?: EditorOptions, desiredPosition ?: Position, ratio ?: number[]): Position;
// private findPosition(input: EditorInput, options ?: EditorOptions, arg1 ?: any, ratio ?: number[]): Position {
// // With defined ratios, always trust the provided position
// if (ratio && types.isNumber(arg1)) {
// return arg1;
// }
// // No editor open
// const visibleEditors = this.getVisibleEditors();
// const activeEditor = this.getActiveEditor();
// if (visibleEditors.length === 0 || !activeEditor) {
// return Position.ONE; // can only be ONE
// }
// // Ignore revealIfVisible/revealIfOpened option if we got instructed explicitly to
// // * open at a specific index
// // * open to the side
// // * open in a specific group
// const skipReveal = (options && options.index) || arg1 === true /* open to side */ || typeof arg1 === 'number' /* open specific group */;
// // Respect option to reveal an editor if it is already visible
// if (!skipReveal && options && options.revealIfVisible) {
// const group = this.stacks.findGroup(input, true);
// if (group) {
// return this.stacks.positionOfGroup(group);
// }
// }
// // Respect option to reveal an editor if it is open (not necessarily visible)
// if (!skipReveal && (this.revealIfOpen /* workbench.editor.revealIfOpen */ || (options && options.revealIfOpened))) {
// const group = this.stacks.findGroup(input);
// if (group) {
// return this.stacks.positionOfGroup(group);
// }
// }
// // Position is unknown: pick last active or ONE
// if (types.isUndefinedOrNull(arg1) || arg1 === false) {
// const lastActivePosition = this.editorGroupsControl.getActivePosition();
// return lastActivePosition || Position.ONE;
// }
// // Position is sideBySide: Find position relative to active editor
// if (arg1 === true) {
// switch (activeEditor.position) {
// case Position.ONE:
// return Position.TWO;
// case Position.TWO:
// return Position.THREE;
// case Position.THREE:
// return null; // Cannot open to the side of the right/bottom most editor
// }
// return null; // Prevent opening to the side
// }
// // Position is provided, validate it
// if (arg1 === Position.THREE && visibleEditors.length === 1) {
// return Position.TWO;
// }
// return arg1;
// }
//#endregion
\ No newline at end of file
}
\ No newline at end of file
src/vs/workbench/services/editor/common/nextEditorGroupsService.ts
浏览文件 @
70c34cd7
...
...
@@ -40,6 +40,12 @@ export interface INextEditorGroup {
*/
openEditor
(
editor
:
IEditorInput
,
options
?:
IEditorOptions
):
Thenable
<
void
>
;
/**
* Find out if the provided editor is opened in the group. An editor can be opened
* but not actively visible.
*/
isOpened
(
editor
:
IEditorInput
):
boolean
;
/**
* Move an editor from this group either within this group or to another group.
*/
...
...
@@ -85,6 +91,7 @@ export interface INextEditorGroupsService {
readonly
activeGroup
:
INextEditorGroup
;
readonly
groups
:
INextEditorGroup
[];
getGroups
(
sortByMostRecentlyActive
?:
boolean
):
INextEditorGroup
[];
getGroup
(
identifier
:
GroupIdentifier
):
INextEditorGroup
;
focusGroup
(
group
:
INextEditorGroup
|
GroupIdentifier
):
INextEditorGroup
;
...
...
src/vs/workbench/services/editor/common/nextEditorService.ts
浏览文件 @
70c34cd7
...
...
@@ -13,7 +13,8 @@ export const INextEditorService = createDecorator<INextEditorService>('nextEdito
export
type
IResourceEditor
=
IResourceInput
|
IUntitledResourceInput
|
IResourceDiffInput
|
IResourceSideBySideInput
;
export
type
SIDE_BY_SIDE
=
-
1
;
export
const
SIDE_BY_SIDE_VALUE
=
-
1
;
export
type
SIDE_BY_SIDE
=
typeof
SIDE_BY_SIDE_VALUE
;
// TODO@grid this should provide convinience methods on top of INextEditorGroupsService to make the 99%
// case of opening editors as simple as possible
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录