Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e02ccd07
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,发现更多精彩内容 >>
提交
e02ccd07
编写于
8月 26, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #79798
上级
185308c0
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
69 addition
and
30 deletion
+69
-30
src/vs/workbench/contrib/files/browser/explorerViewlet.ts
src/vs/workbench/contrib/files/browser/explorerViewlet.ts
+4
-6
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
.../workbench/contrib/files/browser/views/openEditorsView.ts
+1
-5
src/vs/workbench/contrib/search/browser/searchView.ts
src/vs/workbench/contrib/search/browser/searchView.ts
+0
-6
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+63
-12
src/vs/workbench/services/editor/test/browser/editorService.test.ts
...kbench/services/editor/test/browser/editorService.test.ts
+1
-1
未找到文件。
src/vs/workbench/contrib/files/browser/explorerViewlet.ts
浏览文件 @
e02ccd07
...
...
@@ -26,10 +26,9 @@ import { Disposable } from 'vs/base/common/lifecycle';
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IWorkbenchLayoutService
}
from
'
vs/workbench/services/layout/browser/layoutService
'
;
import
{
DelegatingEditorService
}
from
'
vs/workbench/services/editor/browser/editorService
'
;
import
{
IEditorGroup
,
IEditorGroup
sService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorInput
,
IEditor
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditor
}
from
'
vs/workbench/common/editor
'
;
import
{
ViewletPanel
}
from
'
vs/workbench/browser/parts/views/panelViewlet
'
;
import
{
KeyChord
,
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
...
...
@@ -158,7 +157,6 @@ export class ExplorerViewlet extends ViewContainerViewlet {
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IWorkspaceContextService
protected
contextService
:
IWorkspaceContextService
,
@
IStorageService
protected
storageService
:
IStorageService
,
@
IEditorService
private
readonly
editorService
:
IEditorService
,
@
IEditorGroupsService
private
readonly
editorGroupService
:
IEditorGroupsService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
,
...
...
@@ -187,7 +185,7 @@ export class ExplorerViewlet extends ViewContainerViewlet {
// 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
(
DelegatingEditorService
);
delegatingEditorService
.
setEditorOpenHandler
(
async
(
group
:
IEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorO
ptions
):
Promise
<
IEditor
|
null
>
=>
{
delegatingEditorService
.
setEditorOpenHandler
(
async
(
delegate
,
group
,
editor
,
o
ptions
):
Promise
<
IEditor
|
null
>
=>
{
let
openEditorsView
=
this
.
getOpenEditorsView
();
if
(
openEditorsView
)
{
let
delay
=
0
;
...
...
@@ -205,7 +203,7 @@ export class ExplorerViewlet extends ViewContainerViewlet {
let
openedEditor
:
IEditor
|
undefined
;
try
{
openedEditor
=
await
this
.
editorService
.
openEditor
(
editor
,
options
,
group
);
openedEditor
=
await
delegate
(
group
,
editor
,
options
);
}
catch
(
error
)
{
// ignore
}
finally
{
...
...
src/vs/workbench/contrib/files/browser/views/openEditorsView.ts
浏览文件 @
e02ccd07
...
...
@@ -357,11 +357,7 @@ export class OpenEditorsView extends ViewletPanel {
if
(
!
preserveActivateGroup
)
{
this
.
editorGroupService
.
activateGroup
(
element
.
group
);
// needed for https://github.com/Microsoft/vscode/issues/6672
}
this
.
editorService
.
openEditor
(
element
.
editor
,
options
,
options
.
sideBySide
?
SIDE_GROUP
:
element
.
group
).
then
(
editor
=>
{
if
(
editor
&&
!
preserveActivateGroup
&&
editor
.
group
)
{
this
.
editorGroupService
.
activateGroup
(
editor
.
group
);
}
});
this
.
editorService
.
openEditor
(
element
.
editor
,
options
,
options
.
sideBySide
?
SIDE_GROUP
:
element
.
group
);
}
}
...
...
src/vs/workbench/contrib/search/browser/searchView.ts
浏览文件 @
e02ccd07
...
...
@@ -52,7 +52,6 @@ import { IReplaceService } from 'vs/workbench/contrib/search/common/replace';
import
{
getOutOfWorkspaceEditorResources
}
from
'
vs/workbench/contrib/search/common/search
'
;
import
{
FileMatch
,
FileMatchOrMatch
,
FolderMatch
,
IChangeEvent
,
ISearchWorkbenchService
,
Match
,
RenderableMatch
,
searchMatchComparer
,
SearchModel
,
SearchResult
,
BaseFolderMatch
}
from
'
vs/workbench/contrib/search/common/searchModel
'
;
import
{
ACTIVE_GROUP
,
IEditorService
,
SIDE_GROUP
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IPreferencesService
,
ISettingsEditorOptions
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
relativePath
}
from
'
vs/base/common/resources
'
;
...
...
@@ -148,7 +147,6 @@ export class SearchView extends ViewletPanel {
@
IPreferencesService
private
readonly
preferencesService
:
IPreferencesService
,
@
IThemeService
protected
themeService
:
IThemeService
,
@
ISearchHistoryService
private
readonly
searchHistoryService
:
ISearchHistoryService
,
@
IEditorGroupsService
private
readonly
editorGroupsService
:
IEditorGroupsService
,
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
@
IMenuService
private
readonly
menuService
:
IMenuService
,
@
IAccessibilityService
private
readonly
accessibilityService
:
IAccessibilityService
,
...
...
@@ -1570,10 +1568,6 @@ export class SearchView extends ViewletPanel {
}
else
{
this
.
viewModel
.
searchResult
.
rangeHighlightDecorations
.
removeHighlightRange
();
}
if
(
editor
)
{
this
.
editorGroupsService
.
activateGroup
(
editor
.
group
!
);
}
},
errors
.
onUnexpectedError
);
}
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
e02ccd07
...
...
@@ -222,28 +222,59 @@ export class EditorService extends Disposable implements EditorServiceImpl {
openEditor
(
editor
:
IResourceDiffInput
,
group
?:
OpenInEditorGroup
):
Promise
<
ITextDiffEditor
|
undefined
>
;
openEditor
(
editor
:
IResourceSideBySideInput
,
group
?:
OpenInEditorGroup
):
Promise
<
ITextSideBySideEditor
|
undefined
>
;
async
openEditor
(
editor
:
IEditorInput
|
IResourceEditor
,
optionsOrGroup
?:
IEditorOptions
|
ITextEditorOptions
|
OpenInEditorGroup
,
group
?:
OpenInEditorGroup
):
Promise
<
IEditor
|
undefined
>
{
let
resolvedGroup
:
IEditorGroup
|
undefined
;
let
candidateGroup
:
OpenInEditorGroup
|
undefined
;
let
typedEditor
:
IEditorInput
|
undefined
;
let
typedOptions
:
IEditorOptions
|
undefined
;
// Typed Editor Support
if
(
editor
instanceof
EditorInput
)
{
const
editorOptions
=
this
.
toOptions
(
optionsOrGroup
as
IEditorOptions
)
;
const
targetGroup
=
this
.
findTargetGroup
(
editor
,
editorOptions
,
group
);
typedEditor
=
editor
;
typedOptions
=
this
.
toOptions
(
optionsOrGroup
as
IEditorOptions
);
return
this
.
doOpenEditor
(
targetGroup
,
editor
,
editorOptions
);
candidateGroup
=
group
;
resolvedGroup
=
this
.
findTargetGroup
(
typedEditor
,
typedOptions
,
candidateGroup
);
}
// Untyped Text Editor Support
else
{
const
textInput
=
<
IResourceEditor
>
editor
;
const
typedInput
=
this
.
createInput
(
textInput
);
if
(
typedInput
)
{
const
editorOptions
=
TextEditorOptions
.
from
(
textInput
);
const
targetGroup
=
this
.
findTargetGroup
(
typedInput
,
editorOptions
,
optionsOrGroup
as
IEditorGroup
|
GroupIdentifier
);
typedEditor
=
this
.
createInput
(
textInput
);
if
(
typedEditor
)
{
typedOptions
=
TextEditorOptions
.
from
(
textInput
);
return
this
.
doOpenEditor
(
targetGroup
,
typedInput
,
editorOptions
);
candidateGroup
=
optionsOrGroup
as
OpenInEditorGroup
;
resolvedGroup
=
this
.
findTargetGroup
(
typedEditor
,
typedOptions
,
candidateGroup
);
}
}
if
(
typedEditor
&&
resolvedGroup
)
{
const
control
=
await
this
.
doOpenEditor
(
resolvedGroup
,
typedEditor
,
typedOptions
);
this
.
ensureGroupActive
(
resolvedGroup
,
candidateGroup
);
return
control
;
}
return
undefined
;
}
private
ensureGroupActive
(
resolvedGroup
:
IEditorGroup
,
candidateGroup
?:
OpenInEditorGroup
):
void
{
// Ensure we activate the group the editor opens in unless already active. Typically
// an editor always opens in the active group, but there are some cases where the
// target group is not the active one. If `preserveFocus: true` we do not activate
// the target group and as such have to do this manually.
// There is one exception: opening to the side with `preserveFocus: true` will keep
// the current behaviour for historic reasons. The scenario is that repeated Alt-clicking
// of files in the explorer always open into the same side group and not cause a group
// to be created each time.
if
(
this
.
editorGroupService
.
activeGroup
!==
resolvedGroup
&&
candidateGroup
!==
SIDE_GROUP
)
{
this
.
editorGroupService
.
activateGroup
(
resolvedGroup
);
}
}
protected
async
doOpenEditor
(
group
:
IEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
):
Promise
<
IEditor
|
undefined
>
{
return
withNullAsUndefined
(
await
group
.
openEditor
(
editor
,
options
));
}
...
...
@@ -377,14 +408,23 @@ export class EditorService extends Disposable implements EditorServiceImpl {
});
}
// Open in targets
// Open in target
group
s
const
result
:
Promise
<
IEditor
|
null
>
[]
=
[];
let
firstGroup
:
IEditorGroup
|
undefined
;
mapGroupToEditors
.
forEach
((
editorsWithOptions
,
group
)
=>
{
if
(
!
firstGroup
)
{
firstGroup
=
group
;
}
result
.
push
(
group
.
openEditors
(
editorsWithOptions
));
});
const
openedEditors
=
await
Promise
.
all
(
result
);
if
(
firstGroup
)
{
this
.
ensureGroupActive
(
firstGroup
,
group
);
}
return
coalesce
(
openedEditors
);
}
...
...
@@ -625,7 +665,12 @@ export class EditorService extends Disposable implements EditorServiceImpl {
}
export
interface
IEditorOpenHandler
{
(
group
:
IEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
):
Promise
<
IEditor
|
null
>
;
(
delegate
:
(
group
:
IEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
)
=>
Promise
<
IEditor
|
undefined
>
,
group
:
IEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
):
Promise
<
IEditor
|
null
>
;
}
/**
...
...
@@ -662,7 +707,13 @@ export class DelegatingEditorService extends EditorService {
return
super
.
doOpenEditor
(
group
,
editor
,
options
);
}
const
control
=
await
this
.
editorOpenHandler
(
group
,
editor
,
options
);
const
control
=
await
this
.
editorOpenHandler
(
(
group
:
IEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
)
=>
super
.
doOpenEditor
(
group
,
editor
,
options
),
group
,
editor
,
options
);
if
(
control
)
{
return
control
;
// the opening was handled, so return early
}
...
...
src/vs/workbench/services/editor/test/browser/editorService.test.ts
浏览文件 @
e02ccd07
...
...
@@ -330,7 +330,7 @@ suite('EditorService', () => {
const
inp
=
instantiationService
.
createInstance
(
ResourceEditorInput
,
'
name
'
,
'
description
'
,
URI
.
parse
(
'
my://resource-delegate
'
),
undefined
);
const
delegate
=
instantiationService
.
createInstance
(
DelegatingEditorService
);
delegate
.
setEditorOpenHandler
((
group
:
IEditorGroup
,
input
:
IEditorInput
,
options
?:
EditorOptions
)
=>
{
delegate
.
setEditorOpenHandler
((
delegate
,
group
:
IEditorGroup
,
input
:
IEditorInput
,
options
?:
EditorOptions
)
=>
{
assert
.
strictEqual
(
input
,
inp
);
done
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录