Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ef92f85c
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,发现更多精彩内容 >>
提交
ef92f85c
编写于
5月 20, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - remove old group/editor services
上级
abe0207f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
3 addition
and
744 deletion
+3
-744
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+1
-2
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+2
-9
src/vs/workbench/services/editor/common/editorService.ts
src/vs/workbench/services/editor/common/editorService.ts
+0
-590
src/vs/workbench/services/group/common/groupService.ts
src/vs/workbench/services/group/common/groupService.ts
+0
-141
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+0
-2
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
ef92f85c
...
...
@@ -28,7 +28,6 @@ import { Scope } from 'vs/workbench/common/memento';
import
{
ISerializedEditorGroup
,
isSerializedEditorGroup
}
from
'
vs/workbench/common/editor/editorGroup
'
;
import
{
TValueCallback
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
always
}
from
'
vs/base/common/async
'
;
import
{
GroupOrientation
as
LegacyGroupOrientation
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
INotificationService
,
Severity
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
ILifecycleService
,
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
...
...
@@ -737,7 +736,7 @@ export class EditorPart extends Part implements INextEditorGroupsService, IEdito
interface
ILegacyEditorPartUIState
{
ratio
:
number
[];
groupOrientation
:
LegacyGroupOrientation
;
groupOrientation
:
'
vertical
'
|
'
horizontal
'
;
}
interface
ISerializedLegacyEditorStacksModel
{
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
ef92f85c
...
...
@@ -60,11 +60,9 @@ import { IConfigurationResolverService } from 'vs/workbench/services/configurati
import
{
ConfigurationResolverService
}
from
'
vs/workbench/services/configurationResolver/electron-browser/configurationResolverService
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
ITitleService
}
from
'
vs/workbench/services/title/common/titleService
'
;
import
{
IWorkbenchEditorService
,
WorkbenchEditorService
,
NoOpEditorPart
,
IResourceInputType
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IQuickOpenService
}
from
'
vs/platform/quickOpen/common/quickOpen
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
ClipboardService
}
from
'
vs/platform/clipboard/electron-browser/clipboardService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
...
...
@@ -109,7 +107,7 @@ import { IPCClient } from 'vs/base/parts/ipc/common/ipc';
import
{
registerWindowDriver
}
from
'
vs/platform/driver/electron-browser/driver
'
;
import
{
IPreferencesService
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
PreferencesService
}
from
'
vs/workbench/services/preferences/browser/preferencesService
'
;
import
{
INextEditorService
}
from
'
vs/workbench/services/editor/common/nextEditorService
'
;
import
{
INextEditorService
,
IResourceEditor
}
from
'
vs/workbench/services/editor/common/nextEditorService
'
;
import
{
INextEditorGroupsService
,
GroupDirection
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
import
{
NextEditorService
}
from
'
vs/workbench/services/editor/browser/nextEditorService
'
;
import
{
IExtensionUrlHandler
,
ExtensionUrlHandler
}
from
'
vs/platform/url/electron-browser/inactiveExtensionUrlHandler
'
;
...
...
@@ -387,11 +385,6 @@ export class Workbench extends Disposable implements IPartService {
this
.
editorService
=
this
.
instantiationService
.
createInstance
(
NextEditorService
);
serviceCollection
.
set
(
INextEditorService
,
this
.
editorService
);
// TODO@grid Remove Legacy Editor Services
const
noOpEditorPart
=
new
NoOpEditorPart
(
this
.
instantiationService
);
serviceCollection
.
set
(
IWorkbenchEditorService
,
this
.
instantiationService
.
createInstance
(
WorkbenchEditorService
,
noOpEditorPart
));
serviceCollection
.
set
(
IEditorGroupService
,
noOpEditorPart
);
// Title bar
this
.
titlebarPart
=
this
.
instantiationService
.
createInstance
(
TitlebarPart
,
Identifiers
.
TITLEBAR_PART
);
this
.
_register
(
toDisposable
(()
=>
this
.
titlebarPart
.
shutdown
()));
...
...
@@ -714,7 +707,7 @@ export class Workbench extends Disposable implements IPartService {
return
restore
;
}
private
resolveEditorsToOpen
():
TPromise
<
IResource
InputType
[]
>
{
private
resolveEditorsToOpen
():
TPromise
<
IResource
Editor
[]
>
{
const
config
=
this
.
workbenchParams
.
configuration
;
// Files to open, diff or create
...
...
src/vs/workbench/services/editor/common/editorService.ts
已删除
100644 → 0
浏览文件 @
abe0207f
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
createDecorator
,
ServiceIdentifier
,
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEditorOptions
,
ITextEditorOptions
,
Position
,
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
basename
}
from
'
vs/base/common/paths
'
;
import
{
EditorInput
,
EditorOptions
,
TextEditorOptions
,
Extensions
as
EditorExtensions
,
IResourceDiffInput
,
IResourceSideBySideInput
,
IUntitledResourceInput
,
SideBySideEditorInput
,
IFileEditorInput
,
IFileInputFactory
,
IEditorInputFactoryRegistry
,
IEditorOpeningEvent
,
IEditorCloseEvent
,
IEditorIdentifier
,
CloseDirection
,
IEditor
,
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
getPathLabel
}
from
'
vs/base/common/labels
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
Event
,
Emitter
,
once
}
from
'
vs/base/common/event
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
DataUriEditorInput
}
from
'
vs/workbench/common/editor/dataUriEditorInput
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IEditorGroupService
,
IEditorTabOptions
,
GroupArrangement
}
from
'
vs/workbench/services/group/common/groupService
'
;
export
const
IWorkbenchEditorService
=
createDecorator
<
IWorkbenchEditorService
>
(
'
editorService
'
);
export
type
IResourceInputType
=
IResourceInput
|
IUntitledResourceInput
|
IResourceDiffInput
|
IResourceSideBySideInput
;
export
type
ICloseEditorsFilter
=
{
except
?:
IEditorInput
,
direction
?:
CloseDirection
,
savedOnly
?:
boolean
};
/**
* The editor service allows to open editors and work on the active
* editor input and models.
*/
export
interface
IWorkbenchEditorService
{
_serviceBrand
:
ServiceIdentifier
<
any
>
;
/**
* Returns the currently active editor or null if none.
*/
getActiveEditor
():
IEditor
;
/**
* Returns the currently active editor input or null if none.
*/
getActiveEditorInput
():
IEditorInput
;
/**
* Returns an array of visible editors.
*/
getVisibleEditors
():
IEditor
[];
/**
* Opens an Editor on the given input with the provided options at the given position. If sideBySide parameter
* is provided, causes the editor service to decide in what position to open the input.
*/
openEditor
(
input
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
position
?:
Position
):
TPromise
<
IEditor
>
;
openEditor
(
input
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
/**
* Specific overload to open an instance of IResourceInput, IResourceDiffInput or IResourceSideBySideInput.
*/
openEditor
(
input
:
IResourceInputType
,
position
?:
Position
):
TPromise
<
IEditor
>
;
openEditor
(
input
:
IResourceInputType
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
/**
* Similar to #openEditor() but allows to open multiple editors for different positions at the same time. If there are
* more than one editor per position, only the first one will be active and the others stacked behind inactive.
*/
openEditors
(
editors
:
{
input
:
IResourceInputType
,
position
?:
Position
}[]):
TPromise
<
IEditor
[]
>
;
openEditors
(
editors
:
{
input
:
IEditorInput
,
position
?:
Position
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[]):
TPromise
<
IEditor
[]
>
;
openEditors
(
editors
:
{
input
:
IResourceInputType
}[],
sideBySide
?:
boolean
):
TPromise
<
IEditor
[]
>
;
openEditors
(
editors
:
{
input
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[],
sideBySide
?:
boolean
):
TPromise
<
IEditor
[]
>
;
/**
* Given a list of editors to replace, will look across all groups where this editor is open (active or hidden)
* and replace it with the new editor and the provied options.
*/
replaceEditors
(
editors
:
{
toReplace
:
IResourceInputType
,
replaceWith
:
IResourceInputType
}[],
position
?:
Position
):
TPromise
<
IEditor
[]
>
;
replaceEditors
(
editors
:
{
toReplace
:
IEditorInput
,
replaceWith
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[],
position
?:
Position
):
TPromise
<
IEditor
[]
>
;
/**
* Closes the editor at the provided position.
*/
closeEditor
(
position
:
Position
,
input
:
IEditorInput
):
TPromise
<
void
>
;
/**
* Closes all editors of the provided groups, or all editors across all groups
* if no position is provided.
*/
closeEditors
(
positions
?:
Position
[]):
TPromise
<
void
>
;
/**
* Closes editors of a specific group at the provided position. If the optional editor is provided to exclude, it
* will not be closed. The direction can be used in that case to control if all other editors should get closed,
* or towards a specific direction.
*/
closeEditors
(
position
:
Position
,
filter
?:
ICloseEditorsFilter
):
TPromise
<
void
>
;
/**
* Closes the provided editors of a specific group at the provided position.
*/
closeEditors
(
position
:
Position
,
editors
:
IEditorInput
[]):
TPromise
<
void
>
;
/**
* Closes specific editors across all groups at once.
*/
closeEditors
(
editors
:
{
positionOne
?:
ICloseEditorsFilter
,
positionTwo
?:
ICloseEditorsFilter
,
positionThree
?:
ICloseEditorsFilter
}):
TPromise
<
void
>
;
/**
* Closes specific editors across all groups at once.
*/
closeEditors
(
editors
:
{
positionOne
?:
IEditorInput
[],
positionTwo
?:
IEditorInput
[],
positionThree
?:
IEditorInput
[]
}):
TPromise
<
void
>
;
/**
* Allows to resolve an untyped input to a workbench typed instanceof editor input
*/
createInput
(
input
:
IResourceInputType
):
IEditorInput
;
}
export
interface
IEditorPart
{
openEditor
(
input
?:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
openEditor
(
input
?:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
position
?:
Position
):
TPromise
<
IEditor
>
;
openEditors
(
editors
:
{
input
:
IEditorInput
,
position
?:
Position
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[]):
TPromise
<
IEditor
[]
>
;
openEditors
(
editors
:
{
input
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[],
sideBySide
?:
boolean
):
TPromise
<
IEditor
[]
>
;
replaceEditors
(
editors
:
{
toReplace
:
IEditorInput
,
replaceWith
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[],
position
?:
Position
):
TPromise
<
IEditor
[]
>
;
closeEditors
(
positions
?:
Position
[]):
TPromise
<
void
>
;
closeEditor
(
position
:
Position
,
input
:
IEditorInput
):
TPromise
<
void
>
;
closeEditors
(
position
:
Position
,
filter
?:
ICloseEditorsFilter
):
TPromise
<
void
>
;
closeEditors
(
position
:
Position
,
editors
:
IEditorInput
[]):
TPromise
<
void
>
;
closeEditors
(
editors
:
{
positionOne
?:
ICloseEditorsFilter
,
positionTwo
?:
ICloseEditorsFilter
,
positionThree
?:
ICloseEditorsFilter
}):
TPromise
<
void
>
;
closeEditors
(
editors
:
{
positionOne
?:
IEditorInput
[],
positionTwo
?:
IEditorInput
[],
positionThree
?:
IEditorInput
[]
}):
TPromise
<
void
>
;
getActiveEditor
():
IEditor
;
getVisibleEditors
():
IEditor
[];
getActiveEditorInput
():
IEditorInput
;
}
export
class
NoOpEditorPart
implements
IEditorPart
,
IEditorGroupService
{
_serviceBrand
:
ServiceIdentifier
<
any
>
;
stacks
:
any
;
constructor
(
private
instantiationService
:
IInstantiationService
)
{
this
.
stacks
=
new
NoOpEditorStacksModel
();
}
onEditorsChanged
:
Event
<
void
>
=
new
Emitter
<
void
>
().
event
;
onEditorOpening
:
Event
<
IEditorOpeningEvent
>
=
new
Emitter
<
IEditorOpeningEvent
>
().
event
;
onEditorOpenFail
:
Event
<
IEditorInput
>
=
new
Emitter
<
IEditorInput
>
().
event
;
onEditorGroupMoved
:
Event
<
void
>
=
new
Emitter
<
void
>
().
event
;
onGroupOrientationChanged
:
Event
<
void
>
=
new
Emitter
<
void
>
().
event
;
onTabOptionsChanged
:
Event
<
IEditorTabOptions
>
=
new
Emitter
<
IEditorTabOptions
>
().
event
;
focusGroup
(...
args
:
any
[])
{
}
activateGroup
(...
args
:
any
[])
{
}
moveGroup
(...
args
:
any
[])
{
}
arrangeGroups
(
arrangement
:
GroupArrangement
):
void
{
}
setGroupOrientation
(
orientation
:
'
vertical
'
|
'
horizontal
'
):
void
{
}
getGroupOrientation
():
'
vertical
'
|
'
horizontal
'
{
return
'
vertical
'
;
}
resizeGroup
(
position
:
Position
,
groupSizeChange
:
number
):
void
{
}
pinEditor
(...
args
:
any
[])
{
}
moveEditor
(...
args
:
any
[])
{
}
getStacksModel
():
any
{
return
this
.
stacks
;
}
getTabOptions
():
IEditorTabOptions
{
return
Object
.
create
(
null
);
}
invokeWithinEditorContext
<
T
>
(
fn
:
(
accessor
:
ServicesAccessor
)
=>
T
):
T
{
return
this
.
instantiationService
.
invokeFunction
(
fn
);
}
openEditor
(...
args
:
any
[])
{
return
TPromise
.
as
(
void
0
);
}
openEditors
(...
args
:
any
[])
{
return
TPromise
.
as
([]);
}
replaceEditors
(
editors
:
{
toReplace
:
IEditorInput
;
replaceWith
:
IEditorInput
;
options
?:
IEditorOptions
|
ITextEditorOptions
;
}[],
position
?:
Position
):
TPromise
<
IEditor
[],
any
>
{
return
TPromise
.
as
(
void
0
);
}
closeEditors
(...
args
:
any
[])
{
return
TPromise
.
as
(
void
0
);
}
closeEditor
(
position
:
Position
,
input
:
IEditorInput
):
TPromise
<
void
,
any
>
{
return
TPromise
.
as
(
void
0
);
}
getActiveEditor
():
IEditor
{
return
null
;
}
getVisibleEditors
():
IEditor
[]
{
return
[];
}
getActiveEditorInput
():
IEditorInput
{
return
null
;
}
hideTabs
(...
args
:
any
[]):
void
{
}
hasEditorsToRestore
():
boolean
{
return
false
;
}
restoreEditors
():
any
{
return
TPromise
.
as
([]);
}
}
export
class
NoOpEditorStacksModel
{
onModelChanged
:
Event
<
any
>
=
new
Emitter
<
any
>
().
event
;
onWillCloseEditor
:
Event
<
IEditorCloseEvent
>
=
new
Emitter
<
IEditorCloseEvent
>
().
event
;
onEditorClosed
:
Event
<
IEditorCloseEvent
>
=
new
Emitter
<
IEditorCloseEvent
>
().
event
;
groups
:
any
[]
=
[];
activeGroup
:
any
;
isActive
(
group
:
any
):
boolean
{
return
false
;
}
getGroup
(
id
:
number
):
any
{
return
null
;
}
positionOfGroup
(
group
:
any
):
Position
{
return
Position
.
ONE
;
}
groupAt
(
position
:
Position
):
any
{
return
null
;
}
next
(
jumpGroups
:
boolean
,
cycleAtEnd
?:
boolean
):
IEditorIdentifier
{
return
null
;
}
previous
(
jumpGroups
:
boolean
,
cycleAtStart
?:
boolean
):
IEditorIdentifier
{
return
null
;
}
last
():
IEditorIdentifier
{
return
null
;
}
isOpen
(
resource
:
URI
):
boolean
{
return
false
;
}
toString
():
string
{
return
''
;
}
}
type
ICachedEditorInput
=
ResourceEditorInput
|
IFileEditorInput
|
DataUriEditorInput
;
export
class
WorkbenchEditorService
implements
IWorkbenchEditorService
{
public
_serviceBrand
:
any
;
private
static
CACHE
:
ResourceMap
<
ICachedEditorInput
>
=
new
ResourceMap
<
ICachedEditorInput
>
();
private
editorPart
:
IEditorPart
|
IWorkbenchEditorService
;
private
fileInputFactory
:
IFileInputFactory
;
constructor
(
editorPart
:
IEditorPart
|
IWorkbenchEditorService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
IWorkspaceContextService
private
workspaceContextService
:
IWorkspaceContextService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IFileService
private
fileService
:
IFileService
)
{
this
.
editorPart
=
editorPart
;
this
.
fileInputFactory
=
Registry
.
as
<
IEditorInputFactoryRegistry
>
(
EditorExtensions
.
EditorInputFactories
).
getFileInputFactory
();
}
public
getActiveEditor
():
IEditor
{
return
this
.
editorPart
.
getActiveEditor
();
}
public
getActiveEditorInput
():
IEditorInput
{
return
this
.
editorPart
.
getActiveEditorInput
();
}
public
getVisibleEditors
():
IEditor
[]
{
return
this
.
editorPart
.
getVisibleEditors
();
}
public
openEditor
(
input
:
IEditorInput
,
options
?:
IEditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
IEditorInput
,
options
?:
IEditorOptions
,
position
?:
Position
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
IResourceInputType
,
position
?:
Position
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
IResourceInputType
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
any
,
arg2
?:
any
,
arg3
?:
any
):
TPromise
<
IEditor
>
{
if
(
!
input
)
{
return
TPromise
.
wrap
<
IEditor
>
(
null
);
}
// Workbench Input Support
if
(
input
instanceof
EditorInput
)
{
return
this
.
doOpenEditor
(
input
,
this
.
toOptions
(
arg2
),
arg3
);
}
// Support opening foreign resources (such as a http link that points outside of the workbench)
const
resourceInput
=
<
IResourceInput
>
input
;
if
(
resourceInput
.
resource
instanceof
URI
)
{
const
schema
=
resourceInput
.
resource
.
scheme
;
if
(
schema
===
Schemas
.
http
||
schema
===
Schemas
.
https
)
{
window
.
open
(
resourceInput
.
resource
.
toString
(
true
));
return
TPromise
.
wrap
<
IEditor
>
(
null
);
}
}
// Untyped Text Editor Support (required for code that uses this service below workbench level)
const
textInput
=
<
IResourceInputType
>
input
;
const
typedInput
=
this
.
createInput
(
textInput
);
if
(
typedInput
)
{
return
this
.
doOpenEditor
(
typedInput
,
TextEditorOptions
.
from
(
textInput
),
arg2
);
}
return
TPromise
.
wrap
<
IEditor
>
(
null
);
}
private
toOptions
(
options
?:
IEditorOptions
|
EditorOptions
):
EditorOptions
{
if
(
!
options
||
options
instanceof
EditorOptions
)
{
return
options
as
EditorOptions
;
}
const
textOptions
:
ITextEditorOptions
=
options
;
if
(
!!
textOptions
.
selection
)
{
return
TextEditorOptions
.
create
(
options
);
}
return
EditorOptions
.
create
(
options
);
}
/**
* Allow subclasses to implement their own behavior for opening editor (see below).
*/
protected
doOpenEditor
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
protected
doOpenEditor
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
position
?:
Position
):
TPromise
<
IEditor
>
;
protected
doOpenEditor
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
arg3
?:
any
):
TPromise
<
IEditor
>
{
return
this
.
editorPart
.
openEditor
(
input
,
options
,
arg3
);
}
public
openEditors
(
editors
:
{
input
:
IResourceInputType
,
position
:
Position
}[]):
TPromise
<
IEditor
[]
>
;
public
openEditors
(
editors
:
{
input
:
IEditorInput
,
position
:
Position
,
options
?:
IEditorOptions
}[]):
TPromise
<
IEditor
[]
>
;
public
openEditors
(
editors
:
{
input
:
IResourceInputType
}[],
sideBySide
?:
boolean
):
TPromise
<
IEditor
[]
>
;
public
openEditors
(
editors
:
{
input
:
IEditorInput
,
options
?:
IEditorOptions
}[],
sideBySide
?:
boolean
):
TPromise
<
IEditor
[]
>
;
public
openEditors
(
editors
:
any
[],
sideBySide
?:
boolean
):
TPromise
<
IEditor
[]
>
{
const
inputs
=
editors
.
map
(
editor
=>
this
.
createInput
(
editor
.
input
));
const
typedInputs
:
{
input
:
IEditorInput
,
position
:
Position
,
options
?:
EditorOptions
}[]
=
inputs
.
map
((
input
,
index
)
=>
{
const
options
=
editors
[
index
].
input
instanceof
EditorInput
?
this
.
toOptions
(
editors
[
index
].
options
)
:
TextEditorOptions
.
from
(
editors
[
index
].
input
);
return
{
input
,
options
,
position
:
editors
[
index
].
position
};
});
return
this
.
editorPart
.
openEditors
(
typedInputs
,
sideBySide
);
}
public
replaceEditors
(
editors
:
{
toReplace
:
IResourceInputType
,
replaceWith
:
IResourceInputType
}[],
position
?:
Position
):
TPromise
<
IEditor
[]
>
;
public
replaceEditors
(
editors
:
{
toReplace
:
IEditorInput
,
replaceWith
:
IEditorInput
,
options
?:
IEditorOptions
}[],
position
?:
Position
):
TPromise
<
IEditor
[]
>
;
public
replaceEditors
(
editors
:
any
[],
position
?:
Position
):
TPromise
<
IEditor
[]
>
{
const
toReplaceInputs
=
editors
.
map
(
editor
=>
this
.
createInput
(
editor
.
toReplace
));
const
replaceWithInputs
=
editors
.
map
(
editor
=>
this
.
createInput
(
editor
.
replaceWith
));
const
typedReplacements
:
{
toReplace
:
IEditorInput
,
replaceWith
:
IEditorInput
,
options
?:
EditorOptions
}[]
=
editors
.
map
((
editor
,
index
)
=>
{
const
options
=
editor
.
toReplace
instanceof
EditorInput
?
this
.
toOptions
(
editor
.
options
)
:
TextEditorOptions
.
from
(
editor
.
replaceWith
);
return
{
toReplace
:
toReplaceInputs
[
index
],
replaceWith
:
replaceWithInputs
[
index
],
options
};
});
return
this
.
editorPart
.
replaceEditors
(
typedReplacements
,
position
);
}
public
closeEditor
(
position
:
Position
,
input
:
IEditorInput
):
TPromise
<
void
>
{
return
this
.
doCloseEditor
(
position
,
input
);
}
protected
doCloseEditor
(
position
:
Position
,
input
:
IEditorInput
):
TPromise
<
void
>
{
return
this
.
editorPart
.
closeEditor
(
position
,
input
);
}
public
closeEditors
(
positions
?:
Position
[]):
TPromise
<
void
>
;
public
closeEditors
(
position
:
Position
,
filter
?:
ICloseEditorsFilter
):
TPromise
<
void
>
;
public
closeEditors
(
position
:
Position
,
editors
:
IEditorInput
[]):
TPromise
<
void
>
;
public
closeEditors
(
editors
:
{
positionOne
?:
ICloseEditorsFilter
,
positionTwo
?:
ICloseEditorsFilter
,
positionThree
?:
ICloseEditorsFilter
}):
TPromise
<
void
>
;
public
closeEditors
(
editors
:
{
positionOne
?:
IEditorInput
[],
positionTwo
?:
IEditorInput
[],
positionThree
?:
IEditorInput
[]
}):
TPromise
<
void
>
;
public
closeEditors
(
positionsOrEditors
:
any
,
filterOrEditors
?:
any
):
TPromise
<
void
>
{
return
this
.
editorPart
.
closeEditors
(
positionsOrEditors
,
filterOrEditors
);
}
public
createInput
(
input
:
IEditorInput
):
EditorInput
;
public
createInput
(
input
:
IResourceInputType
):
EditorInput
;
public
createInput
(
input
:
any
):
IEditorInput
{
// Workbench Input Support
if
(
input
instanceof
EditorInput
)
{
return
input
;
}
// Side by Side Support
const
resourceSideBySideInput
=
<
IResourceSideBySideInput
>
input
;
if
(
resourceSideBySideInput
.
masterResource
&&
resourceSideBySideInput
.
detailResource
)
{
const
masterInput
=
this
.
createInput
({
resource
:
resourceSideBySideInput
.
masterResource
});
const
detailInput
=
this
.
createInput
({
resource
:
resourceSideBySideInput
.
detailResource
});
return
new
SideBySideEditorInput
(
resourceSideBySideInput
.
label
||
masterInput
.
getName
(),
typeof
resourceSideBySideInput
.
description
===
'
string
'
?
resourceSideBySideInput
.
description
:
masterInput
.
getDescription
(),
detailInput
,
masterInput
);
}
// Diff Editor Support
const
resourceDiffInput
=
<
IResourceDiffInput
>
input
;
if
(
resourceDiffInput
.
leftResource
&&
resourceDiffInput
.
rightResource
)
{
const
leftInput
=
this
.
createInput
({
resource
:
resourceDiffInput
.
leftResource
});
const
rightInput
=
this
.
createInput
({
resource
:
resourceDiffInput
.
rightResource
});
const
label
=
resourceDiffInput
.
label
||
nls
.
localize
(
'
compareLabels
'
,
"
{0} ↔ {1}
"
,
this
.
toDiffLabel
(
leftInput
,
this
.
workspaceContextService
,
this
.
environmentService
),
this
.
toDiffLabel
(
rightInput
,
this
.
workspaceContextService
,
this
.
environmentService
));
return
new
DiffEditorInput
(
label
,
resourceDiffInput
.
description
,
leftInput
,
rightInput
);
}
// Untitled file support
const
untitledInput
=
<
IUntitledResourceInput
>
input
;
if
(
!
untitledInput
.
resource
||
typeof
untitledInput
.
filePath
===
'
string
'
||
(
untitledInput
.
resource
instanceof
URI
&&
untitledInput
.
resource
.
scheme
===
Schemas
.
untitled
))
{
return
this
.
untitledEditorService
.
createOrGet
(
untitledInput
.
filePath
?
URI
.
file
(
untitledInput
.
filePath
)
:
untitledInput
.
resource
,
untitledInput
.
language
,
untitledInput
.
contents
,
untitledInput
.
encoding
);
}
// Resource Editor Support
const
resourceInput
=
<
IResourceInput
>
input
;
if
(
resourceInput
.
resource
instanceof
URI
)
{
let
label
=
resourceInput
.
label
;
if
(
!
label
&&
resourceInput
.
resource
.
scheme
!==
Schemas
.
data
)
{
label
=
basename
(
resourceInput
.
resource
.
fsPath
);
// derive the label from the path (but not for data URIs)
}
return
this
.
createOrGet
(
resourceInput
.
resource
,
this
.
instantiationService
,
label
,
resourceInput
.
description
,
resourceInput
.
encoding
);
}
return
null
;
}
private
createOrGet
(
resource
:
URI
,
instantiationService
:
IInstantiationService
,
label
:
string
,
description
:
string
,
encoding
?:
string
):
ICachedEditorInput
{
if
(
WorkbenchEditorService
.
CACHE
.
has
(
resource
))
{
const
input
=
WorkbenchEditorService
.
CACHE
.
get
(
resource
);
if
(
input
instanceof
ResourceEditorInput
)
{
input
.
setName
(
label
);
input
.
setDescription
(
description
);
}
else
if
(
!
(
input
instanceof
DataUriEditorInput
))
{
input
.
setPreferredEncoding
(
encoding
);
}
return
input
;
}
let
input
:
ICachedEditorInput
;
// File
if
(
this
.
fileService
.
canHandleResource
(
resource
))
{
input
=
this
.
fileInputFactory
.
createFileInput
(
resource
,
encoding
,
instantiationService
);
}
// Data URI
else
if
(
resource
.
scheme
===
Schemas
.
data
)
{
input
=
instantiationService
.
createInstance
(
DataUriEditorInput
,
label
,
description
,
resource
);
}
// Resource
else
{
input
=
instantiationService
.
createInstance
(
ResourceEditorInput
,
label
,
description
,
resource
);
}
WorkbenchEditorService
.
CACHE
.
set
(
resource
,
input
);
once
(
input
.
onDispose
)(()
=>
{
WorkbenchEditorService
.
CACHE
.
delete
(
resource
);
});
return
input
;
}
private
toDiffLabel
(
input
:
EditorInput
,
context
:
IWorkspaceContextService
,
environment
:
IEnvironmentService
):
string
{
const
res
=
input
.
getResource
();
// Do not try to extract any paths from simple untitled editors
if
(
res
.
scheme
===
Schemas
.
untitled
&&
!
this
.
untitledEditorService
.
hasAssociatedFilePath
(
res
))
{
return
input
.
getName
();
}
// Otherwise: for diff labels prefer to see the path as part of the label
return
getPathLabel
(
res
.
fsPath
,
context
,
environment
);
}
}
export
interface
IEditorOpenHandler
{
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
position
?:
Position
):
TPromise
<
IEditor
>
;
}
export
interface
IEditorCloseHandler
{
(
position
:
Position
,
input
:
IEditorInput
):
TPromise
<
void
>
;
}
/**
* Subclass of workbench editor service that delegates all calls to the provided editor service. Subclasses can choose to override the behavior
* of openEditor() and closeEditor() by providing a handler.
*
* This gives clients a chance to override the behavior of openEditor() and closeEditor().
*/
export
class
DelegatingWorkbenchEditorService
extends
WorkbenchEditorService
{
private
editorOpenHandler
:
IEditorOpenHandler
;
private
editorCloseHandler
:
IEditorCloseHandler
;
constructor
(
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IWorkspaceContextService
workspaceContextService
:
IWorkspaceContextService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IFileService
fileService
:
IFileService
)
{
super
(
editorService
,
untitledEditorService
,
workspaceContextService
,
instantiationService
,
environmentService
,
fileService
);
}
public
setEditorOpenHandler
(
handler
:
IEditorOpenHandler
):
void
{
this
.
editorOpenHandler
=
handler
;
}
public
setEditorCloseHandler
(
handler
:
IEditorCloseHandler
):
void
{
this
.
editorCloseHandler
=
handler
;
}
protected
doOpenEditor
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
protected
doOpenEditor
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
position
?:
Position
):
TPromise
<
IEditor
>
;
protected
doOpenEditor
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
arg3
?:
any
):
TPromise
<
IEditor
>
{
const
handleOpen
=
this
.
editorOpenHandler
?
this
.
editorOpenHandler
(
input
,
options
,
arg3
)
:
TPromise
.
as
(
void
0
);
return
handleOpen
.
then
(
editor
=>
{
if
(
editor
)
{
return
TPromise
.
as
<
IEditor
>
(
editor
);
}
return
super
.
doOpenEditor
(
input
,
options
,
arg3
);
});
}
protected
doCloseEditor
(
position
:
Position
,
input
:
IEditorInput
):
TPromise
<
void
>
{
const
handleClose
=
this
.
editorCloseHandler
?
this
.
editorCloseHandler
(
position
,
input
)
:
TPromise
.
as
(
void
0
);
return
handleClose
.
then
(()
=>
{
return
super
.
doCloseEditor
(
position
,
input
);
});
}
}
src/vs/workbench/services/group/common/groupService.ts
已删除
100644 → 0
浏览文件 @
abe0207f
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
createDecorator
,
ServiceIdentifier
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorOpeningEvent
,
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
export
enum
GroupArrangement
{
MINIMIZE_OTHERS
,
EVEN
}
export
type
GroupOrientation
=
'
vertical
'
|
'
horizontal
'
;
export
const
IEditorGroupService
=
createDecorator
<
IEditorGroupService
>
(
'
editorGroupService
'
);
export
interface
IEditorTabOptions
{
showTabs
?:
boolean
;
tabCloseButton
?:
'
left
'
|
'
right
'
|
'
off
'
;
tabSizing
?:
'
fit
'
|
'
shrink
'
;
showIcons
?:
boolean
;
previewEditors
?:
boolean
;
labelFormat
?:
'
default
'
|
'
short
'
|
'
medium
'
|
'
long
'
;
iconTheme
?:
string
;
}
export
interface
IMoveOptions
{
index
?:
number
;
inactive
?:
boolean
;
preserveFocus
?:
boolean
;
}
/**
* The editor service allows to open editors and work on the active
* editor input and models.
*/
export
interface
IEditorGroupService
{
_serviceBrand
:
ServiceIdentifier
<
any
>
;
/**
* Emitted when editors or inputs change. Examples: opening, closing of editors. Active editor change.
*/
onEditorsChanged
:
Event
<
void
>
;
/**
* Emitted when an editor is opening. Allows to prevent/replace the opening via the event method.
*/
onEditorOpening
:
Event
<
IEditorOpeningEvent
>
;
/**
* Emitted when opening an editor fails.
*/
onEditorOpenFail
:
Event
<
IEditorInput
>
;
/**
* Emitted when an entire editor group is moved to another position.
*/
onEditorGroupMoved
:
Event
<
void
>
;
/**
* Emitted when the editor group orientation was changed.
*/
onGroupOrientationChanged
:
Event
<
void
>
;
/**
* Emitted when tab options changed.
*/
onTabOptionsChanged
:
Event
<
IEditorTabOptions
>
;
/**
* Keyboard focus the editor group at the provided position.
*/
focusGroup
(
group
:
any
):
void
;
focusGroup
(
position
:
Position
):
void
;
/**
* Activate the editor group at the provided position without moving focus.
*/
activateGroup
(
group
:
any
):
void
;
activateGroup
(
position
:
Position
):
void
;
/**
* Allows to move the editor group from one position to another.
*/
moveGroup
(
from
:
any
,
to
:
any
):
void
;
moveGroup
(
from
:
Position
,
to
:
Position
):
void
;
/**
* Allows to arrange editor groups according to the GroupArrangement enumeration.
*/
arrangeGroups
(
arrangement
:
GroupArrangement
):
void
;
/**
* Changes the editor group layout between vertical and horizontal orientation. Only applies
* if more than one editor is opened.
*/
setGroupOrientation
(
orientation
:
GroupOrientation
):
void
;
/**
* Returns the current editor group layout.
*/
getGroupOrientation
():
GroupOrientation
;
/**
* Resize visible editor groups
*/
resizeGroup
(
position
:
Position
,
groupSizeChange
:
number
):
void
;
/**
* Adds the pinned state to an editor, removing it from being a preview editor.
*/
pinEditor
(
group
:
any
,
input
:
IEditorInput
):
void
;
pinEditor
(
position
:
Position
,
input
:
IEditorInput
):
void
;
/**
* Moves an editor from one group to another. The index in the group is optional.
* The inactive option is applied when moving across groups.
*/
moveEditor
(
input
:
IEditorInput
,
from
:
any
,
to
:
any
,
moveOptions
?:
IMoveOptions
):
void
;
moveEditor
(
input
:
IEditorInput
,
from
:
Position
,
to
:
Position
,
moveOptions
?:
IMoveOptions
):
void
;
/**
* Provides access to the editor stacks model
*/
getStacksModel
():
any
;
/**
* Returns tab options.
*/
getTabOptions
():
IEditorTabOptions
;
/**
* Invoke a function in the context of the active editor.
*/
invokeWithinEditorContext
<
T
>
(
fn
:
(
accessor
:
ServicesAccessor
)
=>
T
):
T
;
}
\ No newline at end of file
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
ef92f85c
...
...
@@ -37,7 +37,6 @@ import { IRawTextContent, ITextFileService } from 'vs/workbench/services/textfil
import
{
parseArgs
}
from
'
vs/platform/environment/node/argv
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
IInstantiationService
,
ServicesAccessor
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
...
...
@@ -181,7 +180,6 @@ export class TestTextFileService extends TextFileService {
@
ILifecycleService
lifecycleService
:
ILifecycleService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IFileService
fileService
:
IFileService
,
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录