Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
fd476760
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,发现更多精彩内容 >>
提交
fd476760
编写于
6月 16, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
editor - document dispose better
上级
12791da1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
43 deletion
+45
-43
src/vs/workbench/browser/parts/editor/editorGroupView.ts
src/vs/workbench/browser/parts/editor/editorGroupView.ts
+12
-10
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+22
-22
src/vs/workbench/common/editor/editorGroup.ts
src/vs/workbench/common/editor/editorGroup.ts
+2
-2
src/vs/workbench/test/browser/parts/editor/editorGroups.test.ts
.../workbench/test/browser/parts/editor/editorGroups.test.ts
+9
-9
未找到文件。
src/vs/workbench/browser/parts/editor/editorGroupView.ts
浏览文件 @
fd476760
...
...
@@ -525,21 +525,23 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
const
editor
=
event
.
editor
;
const
editorsToClose
=
[
editor
];
// Include both sides of side by side editors when being closed
and not opened multiple times
if
(
editor
instanceof
SideBySideEditorInput
&&
!
this
.
accessor
.
groups
.
some
(
groupView
=>
groupView
.
group
.
contains
(
editor
,
{
strictEquals
:
true
}))
)
{
// Include both sides of side by side editors when being closed
if
(
editor
instanceof
SideBySideEditorInput
)
{
editorsToClose
.
push
(
editor
.
master
,
editor
.
details
);
}
// Dispose the editor if it is the last opened one
// including diff editors
editorsToClose
.
forEach
(
editorToClose
=>
{
if
(
!
this
.
accessor
.
groups
.
some
(
groupView
=>
groupView
.
group
.
contains
(
editorToClose
,
{
strictEquals
:
true
,
// only if this input is not shared across editor groups
searchInSideBySideEditors
:
true
// include side by side editor master & details
// For each editor to close, we call dispose() to free up any resources.
// However, certain editors might be shared across multiple editor groups
// (including being visible in side by side / diff editors) and as such we
// only dispose when they are not opened elsewhere.
for
(
const
editor
of
editorsToClose
)
{
if
(
!
this
.
accessor
.
groups
.
some
(
groupView
=>
groupView
.
group
.
contains
(
editor
,
{
strictEquals
:
true
,
// only if this input is not shared across editor groups
supportSideBySide
:
true
// include side by side editor master & details
})))
{
editor
ToClose
.
dispose
();
editor
.
dispose
();
}
}
);
}
/* __GDPR__
"editorClosed" : {
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
fd476760
...
...
@@ -697,6 +697,28 @@ export class SideBySideEditorInput extends EditorInput {
this
.
registerListeners
();
}
private
registerListeners
():
void
{
// When the details or master input gets disposed, dispose this diff editor input
const
onceDetailsDisposed
=
Event
.
once
(
this
.
details
.
onDispose
);
this
.
_register
(
onceDetailsDisposed
(()
=>
{
if
(
!
this
.
isDisposed
())
{
this
.
dispose
();
}
}));
const
onceMasterDisposed
=
Event
.
once
(
this
.
master
.
onDispose
);
this
.
_register
(
onceMasterDisposed
(()
=>
{
if
(
!
this
.
isDisposed
())
{
this
.
dispose
();
}
}));
// Reemit some events from the master side to the outside
this
.
_register
(
this
.
master
.
onDidChangeDirty
(()
=>
this
.
_onDidChangeDirty
.
fire
()));
this
.
_register
(
this
.
master
.
onDidChangeLabel
(()
=>
this
.
_onDidChangeLabel
.
fire
()));
}
get
resource
():
URI
|
undefined
{
return
undefined
;
}
...
...
@@ -759,28 +781,6 @@ export class SideBySideEditorInput extends EditorInput {
return
Object
.
assign
(
descriptor
,
super
.
getTelemetryDescriptor
());
}
private
registerListeners
():
void
{
// When the details or master input gets disposed, dispose this diff editor input
const
onceDetailsDisposed
=
Event
.
once
(
this
.
details
.
onDispose
);
this
.
_register
(
onceDetailsDisposed
(()
=>
{
if
(
!
this
.
isDisposed
())
{
this
.
dispose
();
}
}));
const
onceMasterDisposed
=
Event
.
once
(
this
.
master
.
onDispose
);
this
.
_register
(
onceMasterDisposed
(()
=>
{
if
(
!
this
.
isDisposed
())
{
this
.
dispose
();
}
}));
// Reemit some events from the master side to the outside
this
.
_register
(
this
.
master
.
onDidChangeDirty
(()
=>
this
.
_onDidChangeDirty
.
fire
()));
this
.
_register
(
this
.
master
.
onDidChangeLabel
(()
=>
this
.
_onDidChangeLabel
.
fire
()));
}
matches
(
otherInput
:
unknown
):
boolean
{
if
(
super
.
matches
(
otherInput
)
===
true
)
{
return
true
;
...
...
src/vs/workbench/common/editor/editorGroup.ts
浏览文件 @
fd476760
...
...
@@ -689,13 +689,13 @@ export class EditorGroup extends Disposable {
return
[
this
.
editors
[
index
],
index
];
}
contains
(
candidate
:
EditorInput
,
options
?:
{
s
earchInSideBySideEditors
?:
boolean
,
strictEquals
?:
boolean
}):
boolean
{
contains
(
candidate
:
EditorInput
,
options
?:
{
s
upportSideBySide
?:
boolean
,
strictEquals
?:
boolean
}):
boolean
{
for
(
const
editor
of
this
.
editors
)
{
if
(
this
.
matches
(
editor
,
candidate
,
options
?.
strictEquals
))
{
return
true
;
}
if
(
options
?.
s
earchInSideBySideEditors
&&
editor
instanceof
SideBySideEditorInput
)
{
if
(
options
?.
s
upportSideBySide
&&
editor
instanceof
SideBySideEditorInput
)
{
if
(
this
.
matches
(
editor
.
master
,
candidate
,
options
?.
strictEquals
)
||
this
.
matches
(
editor
.
details
,
candidate
,
options
?.
strictEquals
))
{
return
true
;
}
...
...
src/vs/workbench/test/browser/parts/editor/editorGroups.test.ts
浏览文件 @
fd476760
...
...
@@ -278,10 +278,10 @@ suite('Workbench editor groups', () => {
assert
.
equal
(
group
.
contains
(
input1
),
true
);
assert
.
equal
(
group
.
contains
(
input1
,
{
strictEquals
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
earchInSideBySideEditors
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
upportSideBySide
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input2
),
false
);
assert
.
equal
(
group
.
contains
(
input2
,
{
strictEquals
:
true
}),
false
);
assert
.
equal
(
group
.
contains
(
input2
,
{
s
earchInSideBySideEditors
:
true
}),
false
);
assert
.
equal
(
group
.
contains
(
input2
,
{
s
upportSideBySide
:
true
}),
false
);
assert
.
equal
(
group
.
contains
(
diffInput1
),
false
);
assert
.
equal
(
group
.
contains
(
diffInput2
),
false
);
...
...
@@ -309,7 +309,7 @@ suite('Workbench editor groups', () => {
group
.
closeEditor
(
input1
);
assert
.
equal
(
group
.
contains
(
input1
),
false
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
earchInSideBySideEditors
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
upportSideBySide
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input2
),
true
);
assert
.
equal
(
group
.
contains
(
diffInput1
),
true
);
assert
.
equal
(
group
.
contains
(
diffInput2
),
true
);
...
...
@@ -317,27 +317,27 @@ suite('Workbench editor groups', () => {
group
.
closeEditor
(
input2
);
assert
.
equal
(
group
.
contains
(
input1
),
false
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
earchInSideBySideEditors
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
upportSideBySide
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input2
),
false
);
assert
.
equal
(
group
.
contains
(
input2
,
{
s
earchInSideBySideEditors
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input2
,
{
s
upportSideBySide
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
diffInput1
),
true
);
assert
.
equal
(
group
.
contains
(
diffInput2
),
true
);
group
.
closeEditor
(
diffInput1
);
assert
.
equal
(
group
.
contains
(
input1
),
false
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
earchInSideBySideEditors
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
upportSideBySide
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input2
),
false
);
assert
.
equal
(
group
.
contains
(
input2
,
{
s
earchInSideBySideEditors
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
input2
,
{
s
upportSideBySide
:
true
}),
true
);
assert
.
equal
(
group
.
contains
(
diffInput1
),
false
);
assert
.
equal
(
group
.
contains
(
diffInput2
),
true
);
group
.
closeEditor
(
diffInput2
);
assert
.
equal
(
group
.
contains
(
input1
),
false
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
earchInSideBySideEditors
:
true
}),
false
);
assert
.
equal
(
group
.
contains
(
input1
,
{
s
upportSideBySide
:
true
}),
false
);
assert
.
equal
(
group
.
contains
(
input2
),
false
);
assert
.
equal
(
group
.
contains
(
input2
,
{
s
earchInSideBySideEditors
:
true
}),
false
);
assert
.
equal
(
group
.
contains
(
input2
,
{
s
upportSideBySide
:
true
}),
false
);
assert
.
equal
(
group
.
contains
(
diffInput1
),
false
);
assert
.
equal
(
group
.
contains
(
diffInput2
),
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录