Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
25a11177
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,发现更多精彩内容 >>
提交
25a11177
编写于
5月 26, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid -never instantiate child code editor service
上级
871a9cb2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
40 deletion
+31
-40
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
+3
-40
src/vs/workbench/services/codeEditor/browser/codeEditorService.ts
...orkbench/services/codeEditor/browser/codeEditorService.ts
+28
-0
未找到文件。
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
浏览文件 @
25a11177
...
@@ -11,7 +11,7 @@ import * as nls from 'vs/nls';
...
@@ -11,7 +11,7 @@ import * as nls from 'vs/nls';
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
{
Action
,
IAction
}
from
'
vs/base/common/actions
'
;
import
{
Action
,
IAction
}
from
'
vs/base/common/actions
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
IDiffEditor
,
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IDiffEditorOptions
,
IEditorOptions
as
ICodeEditorOptions
}
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
{
BaseTextEditor
,
IEditorConfiguration
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
import
{
TextEditorOptions
,
EditorInput
,
EditorOptions
,
TEXT_DIFF_EDITOR_ID
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorInputExtensions
,
ITextDiffEditor
}
from
'
vs/workbench/common/editor
'
;
import
{
TextEditorOptions
,
EditorInput
,
EditorOptions
,
TEXT_DIFF_EDITOR_ID
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorInputExtensions
,
ITextDiffEditor
}
from
'
vs/workbench/common/editor
'
;
...
@@ -25,7 +25,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
...
@@ -25,7 +25,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ITextResourceConfigurationService
}
from
'
vs/editor/common/services/resourceConfiguration
'
;
import
{
ITextResourceConfigurationService
}
from
'
vs/editor/common/services/resourceConfiguration
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ScrollType
,
IDiffEditorViewState
,
IDiffEditorModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ScrollType
,
IDiffEditorViewState
,
IDiffEditorModel
}
from
'
vs/editor/common/editorCommon
'
;
...
@@ -34,12 +33,9 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
...
@@ -34,12 +33,9 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
once
}
from
'
vs/base/common/event
'
;
import
{
once
}
from
'
vs/base/common/event
'
;
import
{
DelegatingWorkbenchEditorService
}
from
'
vs/workbench/services/editor/browser/editorService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
IEditorGroup
,
IEditorGroupsService
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
CodeEditorService
}
from
'
vs/workbench/services/codeEditor/browser/codeEditorService
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
/**
/**
* The text editor that leverages the diff text editor for the editing experience.
* The text editor that leverages the diff text editor for the editing experience.
...
@@ -91,40 +87,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
...
@@ -91,40 +87,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
this
.
toggleIgnoreTrimWhitespaceAction
=
new
ToggleIgnoreTrimWhitespaceAction
(
this
.
_actualConfigurationService
);
this
.
toggleIgnoreTrimWhitespaceAction
=
new
ToggleIgnoreTrimWhitespaceAction
(
this
.
_actualConfigurationService
);
this
.
updateIgnoreTrimWhitespaceAction
();
this
.
updateIgnoreTrimWhitespaceAction
();
// Support navigation within the diff editor by overriding the editor service within
return
this
.
instantiationService
.
createInstance
(
DiffEditorWidget
,
parent
,
configuration
);
const
delegatingEditorService
=
this
.
instantiationService
.
createInstance
(
DelegatingWorkbenchEditorService
);
delegatingEditorService
.
setEditorOpenHandler
((
group
:
IEditorGroup
,
input
:
EditorInput
,
options
?:
EditorOptions
)
=>
{
const
activeDiffInput
=
<
DiffEditorInput
>
this
.
input
;
// Check if target group is same as this editor ones
if
(
group
===
this
.
group
&&
input
&&
activeDiffInput
&&
options
instanceof
TextEditorOptions
)
{
// Find out if input matches any of both sides
let
targetEditor
:
ICodeEditor
;
if
(
input
.
matches
(
activeDiffInput
.
modifiedInput
))
{
targetEditor
=
this
.
getControl
().
getModifiedEditor
();
}
else
if
(
input
.
matches
(
activeDiffInput
.
originalInput
))
{
targetEditor
=
this
.
getControl
().
getOriginalEditor
();
}
// Apply if possible
if
(
targetEditor
)
{
options
.
apply
(
targetEditor
,
ScrollType
.
Smooth
);
return
TPromise
.
as
(
this
);
}
}
return
TPromise
.
as
(
null
);
});
// Create a special child of instantiator that will delegate all calls to openEditor() to the same diff editor if the input matches with the modified one
const
diffEditorInstantiator
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
(
[
IEditorService
,
delegatingEditorService
],
[
ICodeEditorService
,
new
CodeEditorService
(
delegatingEditorService
,
this
.
themeService
)]
));
return
diffEditorInstantiator
.
createInstance
(
DiffEditorWidget
,
parent
,
configuration
);
}
}
public
setInput
(
input
:
EditorInput
,
options
:
EditorOptions
,
token
:
CancellationToken
):
Thenable
<
void
>
{
public
setInput
(
input
:
EditorInput
,
options
:
EditorOptions
,
token
:
CancellationToken
):
Thenable
<
void
>
{
...
...
src/vs/workbench/services/codeEditor/browser/codeEditorService.ts
浏览文件 @
25a11177
...
@@ -11,6 +11,8 @@ import { IResourceInput } from 'vs/platform/editor/common/editor';
...
@@ -11,6 +11,8 @@ import { IResourceInput } from 'vs/platform/editor/common/editor';
import
{
IEditorService
,
SIDE_GROUP
,
ACTIVE_GROUP
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorService
,
SIDE_GROUP
,
ACTIVE_GROUP
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TextEditorOptions
}
from
'
../../../common/editor
'
;
import
{
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
export
class
CodeEditorService
extends
CodeEditorServiceImpl
{
export
class
CodeEditorService
extends
CodeEditorServiceImpl
{
...
@@ -35,6 +37,32 @@ export class CodeEditorService extends CodeEditorServiceImpl {
...
@@ -35,6 +37,32 @@ export class CodeEditorService extends CodeEditorServiceImpl {
}
}
openCodeEditor
(
input
:
IResourceInput
,
source
:
ICodeEditor
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
{
openCodeEditor
(
input
:
IResourceInput
,
source
:
ICodeEditor
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
{
// Special case: If the active editor is a diff editor and the request to open originates and
// targets the modified side of it, we just apply the request there to prevent opening the modified
// side as separate editor.
const
activeTextEditorWidget
=
this
.
editorService
.
activeTextEditorWidget
;
if
(
input
.
resource
&&
// we need a resource to compare with
input
.
options
&&
// we need options to apply
!
sideBySide
&&
// we need the current active group to be the taret
isDiffEditor
(
activeTextEditorWidget
)
&&
// we only support this for active text diff editors
source
===
activeTextEditorWidget
.
getModifiedEditor
()
&&
// we need the source of this request to be the modified side of the diff editor
input
.
resource
.
toString
()
===
activeTextEditorWidget
.
getModel
().
modified
.
uri
.
toString
()
// we need the input resources to match with modified side
)
{
const
targetEditor
=
activeTextEditorWidget
.
getModifiedEditor
();
const
textOptions
=
TextEditorOptions
.
create
(
input
.
options
);
textOptions
.
apply
(
targetEditor
,
ScrollType
.
Smooth
);
return
TPromise
.
as
(
targetEditor
);
}
// Open using our normal editor service
return
this
.
doOpenCodeEditor
(
input
,
source
,
sideBySide
);
}
private
doOpenCodeEditor
(
input
:
IResourceInput
,
source
:
ICodeEditor
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
{
return
this
.
editorService
.
openEditor
(
input
,
sideBySide
?
SIDE_GROUP
:
ACTIVE_GROUP
).
then
(
control
=>
{
return
this
.
editorService
.
openEditor
(
input
,
sideBySide
?
SIDE_GROUP
:
ACTIVE_GROUP
).
then
(
control
=>
{
if
(
control
)
{
if
(
control
)
{
const
widget
=
control
.
getControl
();
const
widget
=
control
.
getControl
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录