Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cf8014ee
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,发现更多精彩内容 >>
提交
cf8014ee
编写于
5月 12, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - adopt delegating editor service
上级
540a57ef
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
88 addition
and
25 deletion
+88
-25
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
+10
-8
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
...vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
+4
-0
src/vs/workbench/parts/files/electron-browser/explorerViewlet.ts
...workbench/parts/files/electron-browser/explorerViewlet.ts
+14
-15
src/vs/workbench/services/editor/browser/nextEditorService.ts
...vs/workbench/services/editor/browser/nextEditorService.ts
+54
-2
src/vs/workbench/services/group/common/nextEditorGroupsService.ts
...orkbench/services/group/common/nextEditorGroupsService.ts
+6
-0
未找到文件。
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
浏览文件 @
cf8014ee
...
...
@@ -13,7 +13,7 @@ import { Action, IAction } from 'vs/base/common/actions';
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IDiffEditorOptions
,
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IDiffEditorOptions
,
IEditorOptions
as
ICodeEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
BaseTextEditor
,
IEditorConfiguration
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
import
{
TextEditorOptions
,
EditorInput
,
EditorOptions
,
TEXT_DIFF_EDITOR_ID
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorInputExtensions
}
from
'
vs/workbench/common/editor
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
...
...
@@ -27,7 +27,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import
{
ITextResourceConfigurationService
}
from
'
vs/editor/common/services/resourceConfiguration
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IWorkbenchEditorService
,
DelegatingWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
...
...
@@ -38,6 +38,8 @@ import { Registry } from 'vs/platform/registry/common/platform';
import
URI
from
'
vs/base/common/uri
'
;
import
{
getCodeOrDiffEditor
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
once
}
from
'
vs/base/common/event
'
;
import
{
DelegatingWorkbenchEditorService
}
from
'
vs/workbench/services/editor/browser/nextEditorService
'
;
import
{
INextEditorGroup
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
/**
* The text editor that leverages the diff text editor for the editing experience.
...
...
@@ -81,7 +83,7 @@ export class TextDiffEditor extends BaseTextEditor {
return
nls
.
localize
(
'
textDiffEditor
'
,
"
Text Diff Editor
"
);
}
public
createEditorControl
(
parent
:
HTMLElement
,
configuration
:
IEditorOptions
):
IDiffEditor
{
public
createEditorControl
(
parent
:
HTMLElement
,
configuration
:
I
Code
EditorOptions
):
IDiffEditor
{
// Actions
this
.
nextDiffAction
=
new
NavigateAction
(
this
,
true
);
...
...
@@ -91,10 +93,10 @@ export class TextDiffEditor extends BaseTextEditor {
// Support navigation within the diff editor by overriding the editor service within
const
delegatingEditorService
=
this
.
instantiationService
.
createInstance
(
DelegatingWorkbenchEditorService
);
delegatingEditorService
.
setEditorOpenHandler
((
input
:
EditorInput
,
options
?:
EditorOptions
,
arg3
?:
any
)
=>
{
delegatingEditorService
.
setEditorOpenHandler
((
group
:
INextEditorGroup
,
input
:
EditorInput
,
options
?:
EditorOptions
)
=>
{
// Check if
arg4 is a position argument that differs from this editors position
if
(
types
.
isUndefinedOrNull
(
arg3
)
||
arg3
===
false
||
arg3
===
this
.
position
)
{
// Check if
target group is same as this editor ones
if
(
group
.
id
===
this
.
position
)
{
const
activeDiffInput
=
<
DiffEditorInput
>
this
.
input
;
if
(
input
&&
options
&&
activeDiffInput
)
{
...
...
@@ -251,7 +253,7 @@ export class TextDiffEditor extends BaseTextEditor {
return
false
;
}
protected
computeConfiguration
(
configuration
:
IEditorConfiguration
):
IEditorOptions
{
protected
computeConfiguration
(
configuration
:
IEditorConfiguration
):
I
Code
EditorOptions
{
const
editorConfiguration
=
super
.
computeConfiguration
(
configuration
);
// Handle diff editor specially by merging in diffEditor configuration
...
...
@@ -262,7 +264,7 @@ export class TextDiffEditor extends BaseTextEditor {
return
editorConfiguration
;
}
protected
getConfigurationOverrides
():
IEditorOptions
{
protected
getConfigurationOverrides
():
I
Code
EditorOptions
{
const
options
:
IDiffEditorOptions
=
super
.
getConfigurationOverrides
();
options
.
readOnly
=
this
.
isReadOnly
();
...
...
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
浏览文件 @
cf8014ee
...
...
@@ -532,6 +532,10 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
return
this
.
_group
.
activeEditor
;
}
get
previewEditor
():
EditorInput
{
return
this
.
_group
.
previewEditor
;
}
isPinned
(
editor
:
EditorInput
):
boolean
{
return
this
.
_group
.
isPinned
(
editor
);
}
...
...
src/vs/workbench/parts/files/electron-browser/explorerViewlet.ts
浏览文件 @
cf8014ee
...
...
@@ -23,10 +23,8 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import
{
IWorkspaceContextService
,
WorkbenchState
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
EditorInput
,
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
IWorkbenchEditorService
,
DelegatingWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
ViewsRegistry
,
ViewLocation
,
IViewDescriptor
}
from
'
vs/workbench/common/views
'
;
...
...
@@ -34,6 +32,10 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
DelegatingWorkbenchEditorService
}
from
'
vs/workbench/services/editor/browser/nextEditorService
'
;
import
{
INextEditorGroup
,
INextEditorGroupsService
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
import
{
INextEditorService
}
from
'
vs/workbench/services/editor/common/nextEditorService
'
;
import
{
IEditorInput
,
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
export
class
ExplorerViewletViewsContribution
extends
Disposable
implements
IWorkbenchContribution
{
...
...
@@ -153,8 +155,8 @@ export class ExplorerViewlet extends PersistentViewsViewlet implements IExplorer
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IWorkspaceContextService
protected
contextService
:
IWorkspaceContextService
,
@
IStorageService
protected
storageService
:
IStorageService
,
@
I
EditorGroupService
private
editorGroupService
:
IEditorGroup
Service
,
@
I
WorkbenchEditorService
private
editorService
:
IWorkbenchEditor
Service
,
@
I
NextEditorService
private
nextEditorService
:
INextEditor
Service
,
@
I
NextEditorGroupsService
private
nextEditorGroupService
:
INextEditorGroups
Service
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
...
...
@@ -188,20 +190,17 @@ export class ExplorerViewlet extends PersistentViewsViewlet implements IExplorer
// We try to be smart and only use the delay if we recognize that the user action is likely to cause
// a new entry in the opened editors view.
const
delegatingEditorService
=
this
.
instantiationService
.
createInstance
(
DelegatingWorkbenchEditorService
);
delegatingEditorService
.
setEditorOpenHandler
((
input
:
EditorInput
,
options
?:
EditorOptions
,
arg3
?:
any
)
=>
{
delegatingEditorService
.
setEditorOpenHandler
((
group
:
INextEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
)
=>
{
let
openEditorsView
=
this
.
getOpenEditorsView
();
if
(
openEditorsView
)
{
let
delay
=
0
;
const
config
=
this
.
configurationService
.
getValue
<
IFilesConfiguration
>
();
// No need to delay if preview is disabled
const
delayEditorOpeningInOpenedEditors
=
!!
config
.
workbench
.
editor
.
enablePreview
;
if
(
delayEditorOpeningInOpenedEditors
&&
(
arg3
===
false
/* not side by side */
||
typeof
arg3
!==
'
number
'
/* no explicit position */
))
{
const
activeGroup
=
this
.
editorGroupService
.
getStacksModel
().
activeGroup
;
if
(
!
activeGroup
||
!
activeGroup
.
previewEditor
)
{
delay
=
250
;
// a new editor entry is likely because there is either no group or no preview in group
}
const
delayEditorOpeningInOpenedEditors
=
!!
config
.
workbench
.
editor
.
enablePreview
;
// No need to delay if preview is disabled
const
activeGroup
=
this
.
nextEditorGroupService
.
activeGroup
;
if
(
delayEditorOpeningInOpenedEditors
&&
group
===
activeGroup
&&
!
activeGroup
.
previewEditor
)
{
delay
=
250
;
// a new editor entry is likely because there is either no group or no preview in group
}
openEditorsView
.
setStructuralRefreshDelay
(
delay
);
...
...
@@ -216,7 +215,7 @@ export class ExplorerViewlet extends PersistentViewsViewlet implements IExplorer
return
editor
;
};
return
this
.
editorService
.
openEditor
(
input
,
options
,
arg3
).
then
(
onSuccessOrError
,
onSuccessOrError
);
return
this
.
nextEditorService
.
openEditor
(
editor
,
options
,
group
).
then
(
onSuccessOrError
,
onSuccessOrError
);
});
const
explorerInstantiator
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
([
IWorkbenchEditorService
,
delegatingEditorService
]));
...
...
src/vs/workbench/services/editor/browser/nextEditorService.ts
浏览文件 @
cf8014ee
...
...
@@ -172,7 +172,7 @@ export class NextEditorService extends Disposable implements INextEditorService
const
editorOptions
=
this
.
toOptions
(
optionsOrGroup
as
IEditorOptions
);
const
targetGroup
=
this
.
findTargetGroup
(
editor
,
editorOptions
,
group
);
return
t
argetGroup
.
openEditor
(
editor
,
editorOptions
).
then
(()
=>
targetGroup
.
activeControl
);
return
t
his
.
doOpenEditor
(
targetGroup
,
editor
,
editorOptions
);
}
// Throw error for well known foreign resources (such as a http link) (TODO@ben remove me after this has been adopted)
...
...
@@ -191,12 +191,16 @@ export class NextEditorService extends Disposable implements INextEditorService
const
editorOptions
=
TextEditorOptions
.
from
(
textInput
);
const
targetGroup
=
this
.
findTargetGroup
(
typedInput
,
editorOptions
,
optionsOrGroup
as
INextEditorGroup
|
GroupIdentifier
);
return
t
argetGroup
.
openEditor
(
typedInput
,
editorOptions
).
then
(()
=>
targetGroup
.
activeControl
);
return
t
his
.
doOpenEditor
(
targetGroup
,
typedInput
,
editorOptions
);
}
return
TPromise
.
wrap
<
IEditor
>
(
null
);
}
protected
doOpenEditor
(
group
:
INextEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
):
Thenable
<
IEditor
>
{
return
group
.
openEditor
(
editor
,
options
).
then
(()
=>
group
.
activeControl
);
}
private
findTargetGroup
(
input
:
IEditorInput
,
options
?:
IEditorOptions
,
group
?:
INextEditorGroup
|
GroupIdentifier
|
SIDE_GROUP_TYPE
|
ACTIVE_GROUP_TYPE
):
INextEditorGroup
{
let
targetGroup
:
INextEditorGroup
;
...
...
@@ -475,4 +479,52 @@ export class NextEditorService extends Disposable implements INextEditorService
}
//#endregion
}
export
interface
IEditorOpenHandler
{
(
group
:
INextEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
):
Thenable
<
IEditor
>
;
}
/**
* The delegating workbench editor service can be used to override the behaviour of the openEditor()
* method by providing a IEditorOpenHandler.
*/
export
class
DelegatingWorkbenchEditorService
extends
NextEditorService
{
private
editorOpenHandler
:
IEditorOpenHandler
;
constructor
(
@
INextEditorGroupsService
nextEditorGroupsService
:
INextEditorGroupsService
,
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
IWorkspaceContextService
workspaceContextService
:
IWorkspaceContextService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IFileService
fileService
:
IFileService
,
@
IConfigurationService
configurationService
:
IConfigurationService
)
{
super
(
nextEditorGroupsService
,
untitledEditorService
,
workspaceContextService
,
instantiationService
,
environmentService
,
fileService
,
configurationService
);
}
setEditorOpenHandler
(
handler
:
IEditorOpenHandler
):
void
{
this
.
editorOpenHandler
=
handler
;
}
protected
doOpenEditor
(
group
:
INextEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
):
Thenable
<
IEditor
>
{
const
handleOpen
=
this
.
editorOpenHandler
?
this
.
editorOpenHandler
(
group
,
editor
,
options
)
:
TPromise
.
as
(
void
0
);
return
handleOpen
.
then
(
control
=>
{
if
(
control
)
{
return
TPromise
.
as
<
IEditor
>
(
control
);
// the opening was handled, so return early
}
return
super
.
doOpenEditor
(
group
,
editor
,
options
);
});
}
}
\ No newline at end of file
src/vs/workbench/services/group/common/nextEditorGroupsService.ts
浏览文件 @
cf8014ee
...
...
@@ -226,6 +226,12 @@ export interface INextEditorGroup {
*/
readonly
activeEditor
:
IEditorInput
;
/**
* The editor in the group that is in preview mode if any. There can
* only ever be one editor in preview mode.
*/
readonly
previewEditor
:
IEditorInput
;
/**
* The number of opend editors in this group.
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录