Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
57f3b4e8
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,体验更适合开发者的 AI 搜索 >>
提交
57f3b4e8
编写于
12月 20, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - introduce IResourceDiffInput (for #17063)
上级
b09b9a3a
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
70 addition
and
30 deletion
+70
-30
src/vs/platform/editor/common/editor.ts
src/vs/platform/editor/common/editor.ts
+28
-0
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+2
-2
src/vs/workbench/electron-browser/actions.ts
src/vs/workbench/electron-browser/actions.ts
+3
-10
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+5
-3
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+25
-8
src/vs/workbench/services/editor/common/editorService.ts
src/vs/workbench/services/editor/common/editorService.ts
+7
-7
未找到文件。
src/vs/platform/editor/common/editor.ts
浏览文件 @
57f3b4e8
...
...
@@ -55,6 +55,34 @@ export interface IResourceInput {
options
?:
ITextEditorOptions
;
}
export
interface
IResourceDiffInput
{
/**
* The left hand side URI to open inside a diff editor.
*/
leftResource
:
URI
;
/**
* The right hand side URI to open inside a diff editor.
*/
rightResource
:
URI
;
/**
* Label to show for the diff editor
*/
label
?:
string
;
/**
* Description to show for the diff editor
*/
description
?:
string
;
/**
* Optional options to use when opening the text diff input.
*/
options
?:
ITextEditorOptions
;
}
export
interface
IEditorControl
{
}
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
57f3b4e8
...
...
@@ -11,7 +11,7 @@ import types = require('vs/base/common/types');
import
URI
from
'
vs/base/common/uri
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IEditor
,
ICommonCodeEditor
,
IEditorViewState
,
IEditorOptions
as
ICodeEditorOptions
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorInput
,
IEditorModel
,
IEditorOptions
,
ITextEditorOptions
,
IResourceInput
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorInput
,
IEditorModel
,
IEditorOptions
,
ITextEditorOptions
,
IResourceInput
,
IResourceDiffInput
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
SyncDescriptor
,
AsyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
...
...
@@ -577,7 +577,7 @@ export class TextEditorOptions extends EditorOptions {
private
editorViewState
:
IEditorViewState
;
private
editorOptions
:
ICodeEditorOptions
;
public
static
from
(
input
:
IResourceInput
):
TextEditorOptions
{
public
static
from
(
input
:
IResourceInput
|
IResourceDiffInput
):
TextEditorOptions
{
let
options
:
TextEditorOptions
=
null
;
if
(
input
&&
input
.
options
)
{
if
(
input
.
options
.
selection
||
input
.
options
.
forceOpen
||
input
.
options
.
revealIfVisible
||
input
.
options
.
preserveFocus
||
input
.
options
.
pinned
||
input
.
options
.
inactive
||
typeof
input
.
options
.
index
===
'
number
'
)
{
...
...
src/vs/workbench/electron-browser/actions.ts
浏览文件 @
57f3b4e8
...
...
@@ -11,8 +11,6 @@ import { Action } from 'vs/base/common/actions';
import
{
IWindowIPCService
}
from
'
vs/workbench/services/window/electron-browser/windowService
'
;
import
{
IWindowService
,
IWindowsService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
EditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
product
from
'
vs/platform/node/product
'
;
import
pkg
from
'
vs/platform/node/package
'
;
...
...
@@ -608,18 +606,13 @@ export class KeybindingsReferenceAction extends Action {
CommandsRegistry
.
registerCommand
(
'
_workbench.diff
'
,
function
(
accessor
:
ServicesAccessor
,
args
:
[
URI
,
URI
,
string
,
string
])
{
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
let
[
left
,
right
,
label
,
description
]
=
args
;
let
[
left
Resource
,
rightResource
,
label
,
description
]
=
args
;
if
(
!
label
)
{
label
=
nls
.
localize
(
'
diffLeftRightLabel
'
,
"
{0} ⟷ {1}
"
,
left
.
toString
(
true
),
right
.
toString
(
true
));
label
=
nls
.
localize
(
'
diffLeftRightLabel
'
,
"
{0} ⟷ {1}
"
,
left
Resource
.
toString
(
true
),
rightResource
.
toString
(
true
));
}
return
TPromise
.
join
([
editorService
.
createInput
({
resource
:
left
}),
editorService
.
createInput
({
resource
:
right
})]).
then
(
inputs
=>
{
const
[
left
,
right
]
=
inputs
;
const
diff
=
new
DiffEditorInput
(
label
,
description
,
<
EditorInput
>
left
,
<
EditorInput
>
right
);
return
editorService
.
openEditor
(
diff
);
}).
then
(()
=>
{
return
editorService
.
openEditor
({
leftResource
,
rightResource
,
label
,
description
}).
then
(()
=>
{
return
void
0
;
});
});
...
...
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
57f3b4e8
...
...
@@ -47,7 +47,6 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import
{
Keybinding
,
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
getCodeEditor
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
export
interface
IEditableData
{
action
:
IAction
;
...
...
@@ -1216,7 +1215,6 @@ export class CompareResourcesAction extends Action {
tree
:
ITree
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
ICommandService
private
commandService
:
ICommandService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
)
{
super
(
'
workbench.files.action.compareFiles
'
,
CompareResourcesAction
.
computeLabel
());
...
...
@@ -1271,7 +1269,11 @@ export class CompareResourcesAction extends Action {
this
.
tree
.
clearHighlight
();
}
return
this
.
commandService
.
executeCommand
(
'
_workbench.diff
'
,
[
globalResourceToCompare
,
this
.
resource
,
toDiffLabel
(
globalResourceToCompare
,
this
.
resource
,
this
.
contextService
)]);
return
this
.
editorService
.
openEditor
({
leftResource
:
globalResourceToCompare
,
rightResource
:
this
.
resource
,
label
:
toDiffLabel
(
globalResourceToCompare
,
this
.
resource
,
this
.
contextService
)
});
}
}
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
57f3b4e8
...
...
@@ -15,9 +15,11 @@ import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorIn
import
{
UntitledEditorInput
}
from
'
vs/workbench/common/editor/untitledEditorInput
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorInput
,
IEditorOptions
,
ITextEditorOptions
,
Position
,
Direction
,
IEditor
,
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorInput
,
IEditorOptions
,
ITextEditorOptions
,
Position
,
Direction
,
IEditor
,
IResourceInput
,
IResourceDiffInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
AsyncDescriptor0
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
DiffEditorInput
,
toDiffLabel
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
export
interface
IEditorPart
{
openEditor
(
input
?:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
BaseEditor
>
;
...
...
@@ -42,10 +44,11 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
constructor
(
editorPart
:
IEditorPart
|
IWorkbenchEditorService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
IWorkspaceContextService
private
workspaceContextService
:
IWorkspaceContextService
,
@
IInstantiationService
private
instantiationService
?:
IInstantiationService
)
{
this
.
editorPart
=
editorPart
;
this
.
fileInputDescriptor
=
(
<
IEditorRegistry
>
Registry
.
as
(
Extensions
.
Editors
)
).
getDefaultFileInput
();
this
.
fileInputDescriptor
=
Registry
.
as
<
IEditorRegistry
>
(
Extensions
.
Editors
).
getDefaultFileInput
();
}
public
getActiveEditor
():
IEditor
{
...
...
@@ -85,8 +88,8 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
public
openEditor
(
input
:
IEditorInput
,
options
?:
IEditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
IEditorInput
,
options
?:
IEditorOptions
,
position
?:
Position
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
IResourceInput
,
position
?:
Position
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
IResourceInput
|
IResourceDiffInput
,
position
?:
Position
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
IResourceInput
|
IResourceDiffInput
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
public
openEditor
(
input
:
any
,
arg2
?:
any
,
arg3
?:
any
):
TPromise
<
IEditor
>
{
if
(
!
input
)
{
return
TPromise
.
as
<
IEditor
>
(
null
);
...
...
@@ -109,7 +112,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
// Untyped Text Editor Support (required for code that uses this service below workbench level)
const
textInput
=
<
IResourceInput
>
input
;
const
textInput
=
<
IResourceInput
|
IResourceDiffInput
>
input
;
return
this
.
createInput
(
textInput
).
then
(
typedInput
=>
{
if
(
typedInput
)
{
return
this
.
doOpenEditor
(
typedInput
,
TextEditorOptions
.
from
(
textInput
),
arg2
);
...
...
@@ -141,7 +144,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
return
this
.
editorPart
.
openEditor
(
input
,
options
,
arg3
);
}
public
openEditors
(
editors
:
{
input
:
IResourceInput
,
position
:
Position
}[]):
TPromise
<
IEditor
[]
>
;
public
openEditors
(
editors
:
{
input
:
IResourceInput
|
IResourceDiffInput
,
position
:
Position
}[]):
TPromise
<
IEditor
[]
>
;
public
openEditors
(
editors
:
{
input
:
IEditorInput
,
position
:
Position
,
options
?:
IEditorOptions
}[]):
TPromise
<
IEditor
[]
>
;
public
openEditors
(
editors
:
any
[]):
TPromise
<
IEditor
[]
>
{
return
TPromise
.
join
(
editors
.
map
(
editor
=>
this
.
createInput
(
editor
.
input
))).
then
(
inputs
=>
{
...
...
@@ -159,7 +162,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
});
}
public
replaceEditors
(
editors
:
{
toReplace
:
IResourceInput
,
replaceWith
:
IResource
Input
}[]):
TPromise
<
BaseEditor
[]
>
;
public
replaceEditors
(
editors
:
{
toReplace
:
IResourceInput
|
IResourceDiffInput
,
replaceWith
:
IResourceInput
|
IResourceDiff
Input
}[]):
TPromise
<
BaseEditor
[]
>
;
public
replaceEditors
(
editors
:
{
toReplace
:
EditorInput
,
replaceWith
:
EditorInput
,
options
?:
IEditorOptions
}[]):
TPromise
<
BaseEditor
[]
>
;
public
replaceEditors
(
editors
:
any
[]):
TPromise
<
BaseEditor
[]
>
{
return
TPromise
.
join
(
editors
.
map
(
editor
=>
this
.
createInput
(
editor
.
toReplace
))).
then
(
toReplaceInputs
=>
{
...
...
@@ -192,7 +195,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
public
createInput
(
input
:
EditorInput
):
TPromise
<
EditorInput
>
;
public
createInput
(
input
:
IResourceInput
):
TPromise
<
EditorInput
>
;
public
createInput
(
input
:
IResourceInput
|
IResourceDiffInput
):
TPromise
<
EditorInput
>
;
public
createInput
(
input
:
any
):
TPromise
<
IEditorInput
>
{
// Workbench Input Support
...
...
@@ -200,6 +203,18 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
return
TPromise
.
as
<
EditorInput
>
(
input
);
}
// Diff Editor Support
const
resourceDiffInput
=
<
IResourceDiffInput
>
input
;
if
(
resourceDiffInput
.
leftResource
&&
resourceDiffInput
.
rightResource
)
{
return
this
.
createInput
({
resource
:
resourceDiffInput
.
leftResource
}).
then
(
leftInput
=>
{
return
this
.
createInput
({
resource
:
resourceDiffInput
.
rightResource
}).
then
(
rightInput
=>
{
const
label
=
resourceDiffInput
.
label
||
toDiffLabel
(
resourceDiffInput
.
leftResource
,
resourceDiffInput
.
rightResource
,
this
.
workspaceContextService
);
return
new
DiffEditorInput
(
label
,
resourceDiffInput
.
description
,
leftInput
,
rightInput
);
});
});
}
// Base Text Editor Support for inmemory resources
const
resourceInput
=
<
IResourceInput
>
input
;
...
...
@@ -253,11 +268,13 @@ export class DelegatingWorkbenchEditorService extends WorkbenchEditorService {
handler
:
IDelegatingWorkbenchEditorServiceHandler
,
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IWorkspaceContextService
workspaceContextService
:
IWorkspaceContextService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
)
{
super
(
editorService
,
untitledEditorService
,
workspaceContextService
,
instantiationService
);
...
...
src/vs/workbench/services/editor/common/editorService.ts
浏览文件 @
57f3b4e8
...
...
@@ -7,7 +7,7 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
createDecorator
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEditorService
,
IEditor
,
IEditorInput
,
IEditorOptions
,
ITextEditorOptions
,
Position
,
Direction
,
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorService
,
IEditor
,
IEditorInput
,
IEditorOptions
,
ITextEditorOptions
,
Position
,
Direction
,
IResourceInput
,
IResourceDiffInput
}
from
'
vs/platform/editor/common/editor
'
;
export
const
IWorkbenchEditorService
=
createDecorator
<
IWorkbenchEditorService
>
(
'
editorService
'
);
...
...
@@ -49,23 +49,23 @@ export interface IWorkbenchEditorService extends IEditorService {
openEditor
(
input
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
/**
* Specific overload to open an instance of IResourceInput.
* Specific overload to open an instance of IResourceInput
and IResourceDiffInput
.
*/
openEditor
(
input
:
IResourceInput
,
position
?:
Position
):
TPromise
<
IEditor
>
;
openEditor
(
input
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
IEditor
>
;
openEditor
(
input
:
IResourceInput
|
IResourceDiffInput
,
position
?:
Position
):
TPromise
<
IEditor
>
;
openEditor
(
input
:
IResourceInput
|
IResourceDiffInput
,
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
:
IResourceInput
,
position
:
Position
}[]):
TPromise
<
IEditor
[]
>
;
openEditors
(
editors
:
{
input
:
IResourceInput
|
IResourceDiffInput
,
position
:
Position
}[]):
TPromise
<
IEditor
[]
>
;
openEditors
(
editors
:
{
input
:
IEditorInput
,
position
:
Position
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[]):
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
:
IResourceInput
,
replaceWith
:
IResource
Input
}[]):
TPromise
<
IEditor
[]
>
;
replaceEditors
(
editors
:
{
toReplace
:
IResourceInput
|
IResourceDiffInput
,
replaceWith
:
IResourceInput
|
IResourceDiff
Input
}[]):
TPromise
<
IEditor
[]
>
;
replaceEditors
(
editors
:
{
toReplace
:
IEditorInput
,
replaceWith
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[]):
TPromise
<
IEditor
[]
>
;
/**
...
...
@@ -88,5 +88,5 @@ export interface IWorkbenchEditorService extends IEditorService {
/**
* Allows to resolve an untyped input to a workbench typed instanceof editor input
*/
createInput
(
input
:
IResourceInput
):
TPromise
<
IEditorInput
>
;
createInput
(
input
:
IResourceInput
|
IResourceDiffInput
):
TPromise
<
IEditorInput
>
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录