Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
daaf263d
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,发现更多精彩内容 >>
提交
daaf263d
编写于
8月 26, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better fix for #79798
上级
3cb1da6f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
105 addition
and
91 deletion
+105
-91
src/vs/platform/editor/common/editor.ts
src/vs/platform/editor/common/editor.ts
+6
-0
src/vs/workbench/browser/parts/editor/editorGroupView.ts
src/vs/workbench/browser/parts/editor/editorGroupView.ts
+22
-13
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+64
-45
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+13
-33
未找到文件。
src/vs/platform/editor/common/editor.ts
浏览文件 @
daaf263d
...
...
@@ -87,6 +87,12 @@ export interface IEditorOptions {
*/
readonly
preserveFocus
?:
boolean
;
/**
* Tells the group the editor opens in to become active. By default, an editor group will not
* become active if either `preserveFocus: true` or `inactive: true`.
*/
readonly
forceActive
?:
boolean
;
/**
* Tells the editor to reload the editor input in the editor even if it is identical to the one
* already showing. By default, the editor will not reload the input if it is identical to the
...
...
src/vs/workbench/browser/parts/editor/editorGroupView.ts
浏览文件 @
daaf263d
...
...
@@ -831,19 +831,28 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
openEditorOptions
.
active
=
true
;
}
if
(
openEditorOptions
.
active
)
{
// Set group active unless we are instructed to preserveFocus. Always
// make sure to restore a minimized group though in order to fix
// https://github.com/microsoft/vscode/issues/79633
//
// Do this before we open the editor in the group to prevent a false
// active editor change event before the editor is loaded
// (see https://github.com/Microsoft/vscode/issues/51679)
if
(
options
&&
options
.
preserveFocus
)
{
this
.
accessor
.
restoreGroup
(
this
);
}
else
{
this
.
accessor
.
activateGroup
(
this
);
}
let
activateGroup
=
false
;
let
restoreGroup
=
false
;
if
(
options
&&
options
.
forceActive
)
{
// Always respect option to force activate an editor group.
activateGroup
=
true
;
}
else
if
(
openEditorOptions
.
active
)
{
// Otherwise, we only activate/restore an editor which is
// opening as active editor.
// If preserveFocus is enabled, we only restore but never
// activate the group.
activateGroup
=
!
options
||
!
options
.
preserveFocus
;
restoreGroup
=
!
activateGroup
;
}
// Do this before we open the editor in the group to prevent a false
// active editor change event before the editor is loaded
// (see https://github.com/Microsoft/vscode/issues/51679)
if
(
activateGroup
)
{
this
.
accessor
.
activateGroup
(
this
);
}
else
if
(
restoreGroup
)
{
this
.
accessor
.
restoreGroup
(
this
);
}
// Actually move the editor if a specific index is provided and we figure
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
daaf263d
...
...
@@ -707,15 +707,7 @@ export class EditorOptions implements IEditorOptions {
*/
static
create
(
settings
:
IEditorOptions
):
EditorOptions
{
const
options
=
new
EditorOptions
();
options
.
preserveFocus
=
settings
.
preserveFocus
;
options
.
forceReload
=
settings
.
forceReload
;
options
.
revealIfVisible
=
settings
.
revealIfVisible
;
options
.
revealIfOpened
=
settings
.
revealIfOpened
;
options
.
pinned
=
settings
.
pinned
;
options
.
index
=
settings
.
index
;
options
.
inactive
=
settings
.
inactive
;
options
.
ignoreError
=
settings
.
ignoreError
;
options
.
overwrite
(
settings
);
return
options
;
}
...
...
@@ -726,6 +718,12 @@ export class EditorOptions implements IEditorOptions {
*/
preserveFocus
:
boolean
|
undefined
;
/**
* Tells the group the editor opens in to become active. By default, an editor group will not
* become active if either `preserveFocus: true` or `inactive: true`.
*/
forceActive
:
boolean
|
undefined
;
/**
* Tells the editor to reload the editor input in the editor even if it is identical to the one
* already showing. By default, the editor will not reload the input if it is identical to the
...
...
@@ -765,6 +763,49 @@ export class EditorOptions implements IEditorOptions {
* message as needed. By default, an error will be presented as notification if opening was not possible.
*/
ignoreError
:
boolean
|
undefined
;
/**
* Overwrites option values from the provided bag.
*/
overwrite
(
options
:
IEditorOptions
):
EditorOptions
{
if
(
options
.
forceReload
)
{
this
.
forceReload
=
true
;
}
if
(
options
.
revealIfVisible
)
{
this
.
revealIfVisible
=
true
;
}
if
(
options
.
revealIfOpened
)
{
this
.
revealIfOpened
=
true
;
}
if
(
options
.
preserveFocus
)
{
this
.
preserveFocus
=
true
;
}
if
(
options
.
forceActive
)
{
this
.
forceActive
=
true
;
}
if
(
options
.
pinned
)
{
this
.
pinned
=
true
;
}
if
(
options
.
inactive
)
{
this
.
inactive
=
true
;
}
if
(
options
.
ignoreError
)
{
this
.
ignoreError
=
true
;
}
if
(
typeof
options
.
index
===
'
number
'
)
{
this
.
index
=
options
.
index
;
}
return
this
;
}
}
/**
...
...
@@ -792,53 +833,31 @@ export class TextEditorOptions extends EditorOptions {
*/
static
create
(
options
:
ITextEditorOptions
=
Object
.
create
(
null
)):
TextEditorOptions
{
const
textEditorOptions
=
new
TextEditorOptions
();
textEditorOptions
.
overwrite
(
options
);
return
textEditorOptions
;
}
/**
* Overwrites option values from the provided bag.
*/
overwrite
(
options
:
ITextEditorOptions
):
TextEditorOptions
{
super
.
overwrite
(
options
);
if
(
options
.
selection
)
{
const
selection
=
options
.
selection
;
t
extEditorOption
s
.
selection
(
selection
.
startLineNumber
,
selection
.
startColumn
,
selection
.
endLineNumber
,
selection
.
endColumn
);
t
hi
s
.
selection
(
selection
.
startLineNumber
,
selection
.
startColumn
,
selection
.
endLineNumber
,
selection
.
endColumn
);
}
if
(
options
.
viewState
)
{
textEditorOptions
.
editorViewState
=
options
.
viewState
as
IEditorViewState
;
}
if
(
options
.
forceReload
)
{
textEditorOptions
.
forceReload
=
true
;
}
if
(
options
.
revealIfVisible
)
{
textEditorOptions
.
revealIfVisible
=
true
;
}
if
(
options
.
revealIfOpened
)
{
textEditorOptions
.
revealIfOpened
=
true
;
}
if
(
options
.
preserveFocus
)
{
textEditorOptions
.
preserveFocus
=
true
;
this
.
editorViewState
=
options
.
viewState
as
IEditorViewState
;
}
if
(
options
.
revealInCenterIfOutsideViewport
)
{
textEditorOptions
.
revealInCenterIfOutsideViewport
=
true
;
}
if
(
options
.
pinned
)
{
textEditorOptions
.
pinned
=
true
;
}
if
(
options
.
inactive
)
{
textEditorOptions
.
inactive
=
true
;
this
.
revealInCenterIfOutsideViewport
=
true
;
}
if
(
options
.
ignoreError
)
{
textEditorOptions
.
ignoreError
=
true
;
}
if
(
typeof
options
.
index
===
'
number
'
)
{
textEditorOptions
.
index
=
options
.
index
;
}
return
textEditorOptions
;
return
this
;
}
/**
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
daaf263d
...
...
@@ -225,8 +225,8 @@ export class EditorService extends Disposable implements EditorServiceImpl {
let
resolvedGroup
:
IEditorGroup
|
undefined
;
let
candidateGroup
:
OpenInEditorGroup
|
undefined
;
let
typedEditor
:
I
EditorInput
|
undefined
;
let
typedOptions
:
I
EditorOptions
|
undefined
;
let
typedEditor
:
EditorInput
|
undefined
;
let
typedOptions
:
EditorOptions
|
undefined
;
// Typed Editor Support
if
(
editor
instanceof
EditorInput
)
{
...
...
@@ -250,31 +250,22 @@ export class EditorService extends Disposable implements EditorServiceImpl {
}
if
(
typedEditor
&&
resolvedGroup
)
{
const
control
=
await
this
.
doOpenEditor
(
resolvedGroup
,
typedEditor
,
typedOptions
);
this
.
ensureGroupActive
(
resolvedGroup
,
candidateGroup
);
// Unless the editor opens as inactive editor or we are instructed to open a side group,
// ensure that the group gets activated even if preserveFocus: true.
//
// Not enforcing this for side groups supports a historic scenario we have: 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
(
typedOptions
&&
!
typedOptions
.
inactive
&&
typedOptions
.
preserveFocus
&&
candidateGroup
!==
SIDE_GROUP
)
{
typedOptions
.
overwrite
({
forceActive
:
true
});
}
return
control
;
return
this
.
doOpenEditor
(
resolvedGroup
,
typedEditor
,
typedOptions
)
;
}
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
));
}
...
...
@@ -410,22 +401,11 @@ export class EditorService extends Disposable implements EditorServiceImpl {
// Open in target groups
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
);
return
coalesce
(
await
Promise
.
all
(
result
));
}
//#endregion
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录