Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6b0bcc2d
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,发现更多精彩内容 >>
提交
6b0bcc2d
编写于
5月 06, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - implement invokeWithinContext()
上级
12ec4483
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
84 addition
and
22 deletion
+84
-22
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+14
-18
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
...vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
+9
-1
src/vs/workbench/services/editor/browser/nextEditorService.ts
...vs/workbench/services/editor/browser/nextEditorService.ts
+27
-1
src/vs/workbench/services/editor/common/nextEditorGroupsService.ts
...rkbench/services/editor/common/nextEditorGroupsService.ts
+6
-1
src/vs/workbench/services/editor/common/nextEditorService.ts
src/vs/workbench/services/editor/common/nextEditorService.ts
+13
-1
src/vs/workbench/test/browser/parts/editor2/nextEditorPart.test.ts
...rkbench/test/browser/parts/editor2/nextEditorPart.test.ts
+15
-0
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
6b0bcc2d
...
...
@@ -613,24 +613,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
//#endregion
//#region TODO@grid invokeWithinEditorContext()
public
invokeWithinEditorContext
<
T
>
(
fn
:
(
accessor
:
ServicesAccessor
)
=>
T
):
T
{
const
activeEditor
=
this
.
getActiveEditor
();
if
(
activeEditor
)
{
const
activeEditorControl
=
activeEditor
.
getControl
();
if
(
isCodeEditor
(
activeEditorControl
))
{
return
activeEditorControl
.
invokeWithinContext
(
fn
);
}
return
this
.
editorGroupsControl
.
getInstantiationService
(
activeEditor
.
position
).
invokeFunction
(
fn
);
}
return
this
.
instantiationService
.
invokeFunction
(
fn
);
}
//#endregion
//#region Handled or Adopted or Obsolete
public
_serviceBrand
:
any
;
...
...
@@ -738,6 +720,20 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this
.
registerListeners
();
}
public
invokeWithinEditorContext
<
T
>
(
fn
:
(
accessor
:
ServicesAccessor
)
=>
T
):
T
{
const
activeEditor
=
this
.
getActiveEditor
();
if
(
activeEditor
)
{
const
activeEditorControl
=
activeEditor
.
getControl
();
if
(
isCodeEditor
(
activeEditorControl
))
{
return
activeEditorControl
.
invokeWithinContext
(
fn
);
}
return
this
.
editorGroupsControl
.
getInstantiationService
(
activeEditor
.
position
).
invokeFunction
(
fn
);
}
return
this
.
instantiationService
.
invokeFunction
(
fn
);
}
private
initStyles
():
void
{
// Letterpress Background when Empty
...
...
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
浏览文件 @
6b0bcc2d
...
...
@@ -10,7 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
EditorGroup
,
IEditorOpenOptions
,
EditorCloseEvent
}
from
'
vs/workbench/common/editor/editorStacksModel
'
;
import
{
EditorInput
,
EditorOptions
,
GroupIdentifier
,
ConfirmResult
,
SideBySideEditorInput
,
IEditorOpeningEvent
,
EditorOpeningEvent
,
TextEditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
Event
,
Emitter
,
once
}
from
'
vs/base/common/event
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
addClass
,
addClasses
,
Dimension
,
trackFocus
,
toggleClass
,
removeClass
,
addDisposableListener
,
EventType
,
EventHelper
,
findParentWithClass
,
clearNode
,
isAncestor
}
from
'
vs/base/browser/dom
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
@@ -514,6 +514,14 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
}
}
invokeWithinContext
<
T
>
(
fn
:
(
accessor
:
ServicesAccessor
)
=>
T
):
T
{
if
(
!
this
.
scopedInstantiationService
)
{
this
.
createScopedInstantiationService
();
}
return
this
.
scopedInstantiationService
.
invokeFunction
(
fn
);
}
//#endregion
//#region openEditor()
...
...
src/vs/workbench/services/editor/browser/nextEditorService.ts
浏览文件 @
6b0bcc2d
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEditorInput
,
IResourceInput
,
IUntitledResourceInput
,
IResourceDiffInput
,
IResourceSideBySideInput
,
IEditor
,
ITextEditorOptions
,
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
GroupIdentifier
,
IFileEditorInput
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorExtensions
,
IFileInputFactory
,
EditorInput
,
SideBySideEditorInput
,
EditorOptions
,
TextEditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
...
...
@@ -29,6 +29,7 @@ import { INextEditorService, IResourceEditor, SIDE_BY_SIDE, SIDE_BY_SIDE_VALUE }
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
Disposable
,
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
isCodeEditor
,
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
type
ICachedEditorInput
=
ResourceEditorInput
|
IFileEditorInput
|
DataUriEditorInput
;
...
...
@@ -98,6 +99,18 @@ export class NextEditorService extends Disposable implements INextEditorService
return
this
.
nextEditorGroupsService
.
activeGroup
.
activeControl
;
}
get
activeTextEditorControl
():
ICodeEditor
{
const
activeControl
=
this
.
activeControl
;
if
(
activeControl
)
{
const
activeControlWidget
=
activeControl
.
getControl
();
if
(
isCodeEditor
(
activeControlWidget
))
{
return
activeControlWidget
;
}
}
return
void
0
;
}
get
activeEditor
():
IEditorInput
{
return
this
.
nextEditorGroupsService
.
activeGroup
.
activeEditor
;
}
...
...
@@ -203,6 +216,19 @@ export class NextEditorService extends Disposable implements INextEditorService
//#endregion
//#region invokeWithinEditorContext()
invokeWithinEditorContext
<
T
>
(
fn
:
(
accessor
:
ServicesAccessor
)
=>
T
):
T
{
const
activeTextEditorControl
=
this
.
activeTextEditorControl
;
if
(
activeTextEditorControl
)
{
return
activeTextEditorControl
.
invokeWithinContext
(
fn
);
}
return
this
.
nextEditorGroupsService
.
activeGroup
.
invokeWithinContext
(
fn
);
}
//#endregion
//#region createInput()
createInput
(
input
:
IEditorInput
|
IResourceEditor
):
EditorInput
{
...
...
src/vs/workbench/services/editor/common/nextEditorGroupsService.ts
浏览文件 @
6b0bcc2d
...
...
@@ -6,7 +6,7 @@
'
use strict
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
createDecorator
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
createDecorator
,
ServiceIdentifier
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
GroupIdentifier
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditorInput
,
IEditor
,
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
...
...
@@ -125,6 +125,11 @@ export interface INextEditorGroup {
* Move keyboard focus into the group.
*/
focus
():
void
;
/**
* Invoke a function in the context of the services of this group.
*/
invokeWithinContext
<
T
>
(
fn
:
(
accessor
:
ServicesAccessor
)
=>
T
):
T
;
}
export
enum
CopyKind
{
...
...
src/vs/workbench/services/editor/common/nextEditorService.ts
浏览文件 @
6b0bcc2d
...
...
@@ -5,10 +5,11 @@
'
use strict
'
;
import
{
createDecorator
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
createDecorator
,
ServiceIdentifier
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEditorInput
,
IResourceInput
,
IUntitledResourceInput
,
IResourceDiffInput
,
IResourceSideBySideInput
,
IEditor
,
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
GroupIdentifier
}
from
'
vs/workbench/common/editor
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IEditor
as
ICodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
export
const
INextEditorService
=
createDecorator
<
INextEditorService
>
(
'
nextEditorService
'
);
...
...
@@ -35,6 +36,12 @@ export interface INextEditorService {
*/
readonly
activeControl
:
IEditor
;
/**
* The currently active text editor control if there is a control active
* and it is an instance of the code text editor.
*/
readonly
activeTextEditorControl
:
ICodeEditor
;
/**
* The currently active editor if any.
*/
...
...
@@ -71,6 +78,11 @@ export interface INextEditorService {
*/
openEditor
(
editor
:
IResourceEditor
,
group
?:
GroupIdentifier
|
SIDE_BY_SIDE
):
Thenable
<
IEditor
>
;
/**
* Invoke a function in the context of the services of the active editor.
*/
invokeWithinEditorContext
<
T
>
(
fn
:
(
accessor
:
ServicesAccessor
)
=>
T
):
T
;
/**
* Converts a lightweight input to a workbench editor input.
*/
...
...
src/vs/workbench/test/browser/parts/editor2/nextEditorPart.test.ts
浏览文件 @
6b0bcc2d
...
...
@@ -10,6 +10,7 @@ import { NextEditorPart } from 'vs/workbench/browser/parts/editor2/nextEditorPar
import
{
workbenchInstantiationService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
Direction
}
from
'
vs/workbench/services/editor/common/nextEditorGroupsService
'
;
import
{
Dimension
}
from
'
vs/base/browser/dom
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
suite
(
'
editor2 tests
'
,
()
=>
{
...
...
@@ -86,6 +87,20 @@ suite('editor2 tests', () => {
assert
.
equal
(
mru
[
0
],
rightGroup
);
assert
.
equal
(
mru
[
1
],
rootGroup
);
let
rightGroupInstantiator
:
IInstantiationService
;
part
.
activeGroup
.
invokeWithinContext
(
accessor
=>
{
rightGroupInstantiator
=
accessor
.
get
(
IInstantiationService
);
});
let
rootGroupInstantiator
:
IInstantiationService
;
rootGroup
.
invokeWithinContext
(
accessor
=>
{
rootGroupInstantiator
=
accessor
.
get
(
IInstantiationService
);
});
assert
.
ok
(
rightGroupInstantiator
);
assert
.
ok
(
rootGroupInstantiator
);
assert
.
ok
(
rightGroupInstantiator
!==
rootGroupInstantiator
);
part
.
removeGroup
(
rightGroup
);
assert
.
equal
(
part
.
groups
.
length
,
1
);
assert
.
ok
(
part
.
activeGroup
===
rootGroup
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录