Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4c54f712
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,发现更多精彩内容 >>
提交
4c54f712
编写于
5月 18, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shared document between split editors and dispose them properly
上级
55ac4527
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
58 addition
and
11 deletion
+58
-11
extensions/vscode-notebook-tests/src/notebook.test.ts
extensions/vscode-notebook-tests/src/notebook.test.ts
+25
-0
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+33
-11
未找到文件。
extensions/vscode-notebook-tests/src/notebook.test.ts
浏览文件 @
4c54f712
...
...
@@ -383,6 +383,31 @@ suite('notebook working copy', () => {
await
vscode
.
commands
.
executeCommand
(
'
workbench.action.files.saveAll
'
);
await
vscode
.
commands
.
executeCommand
(
'
workbench.action.closeAllEditors
'
);
});
test
(
'
multiple tabs: different editors with same document
'
,
async
function
()
{
const
resource
=
vscode
.
Uri
.
parse
(
join
(
vscode
.
workspace
.
rootPath
||
''
,
'
./first.vsctestnb
'
));
await
vscode
.
commands
.
executeCommand
(
'
vscode.openWith
'
,
resource
,
'
notebookCoreTest
'
);
await
waitFor
(
500
);
const
firstNotebookEditor
=
vscode
.
notebook
.
activeNotebookEditor
;
assert
.
equal
(
firstNotebookEditor
!==
undefined
,
true
,
'
notebook first
'
);
assert
.
equal
(
firstNotebookEditor
!
.
selection
?.
source
,
'
test
'
);
assert
.
equal
(
firstNotebookEditor
!
.
selection
?.
language
,
'
typescript
'
);
await
vscode
.
commands
.
executeCommand
(
'
workbench.action.splitEditor
'
);
const
secondNotebookEditor
=
vscode
.
notebook
.
activeNotebookEditor
;
assert
.
equal
(
secondNotebookEditor
!==
undefined
,
true
,
'
notebook first
'
);
assert
.
equal
(
secondNotebookEditor
!
.
selection
?.
source
,
'
test
'
);
assert
.
equal
(
secondNotebookEditor
!
.
selection
?.
language
,
'
typescript
'
);
assert
.
notEqual
(
firstNotebookEditor
,
secondNotebookEditor
);
assert
.
equal
(
firstNotebookEditor
?.
document
,
secondNotebookEditor
?.
document
,
'
split notebook editors share the same document
'
);
assert
.
notEqual
(
firstNotebookEditor
?.
asWebviewUri
(
vscode
.
Uri
.
parse
(
'
./hello.png
'
)),
secondNotebookEditor
?.
asWebviewUri
(
vscode
.
Uri
.
parse
(
'
./hello.png
'
)));
await
vscode
.
commands
.
executeCommand
(
'
workbench.action.files.saveAll
'
);
await
vscode
.
commands
.
executeCommand
(
'
workbench.action.closeAllEditors
'
);
});
});
suite
(
'
metadata
'
,
()
=>
{
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
4c54f712
...
...
@@ -219,6 +219,8 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
return
this
.
_versionId
;
}
private
_disposed
=
false
;
constructor
(
private
readonly
_proxy
:
MainThreadNotebookShape
,
private
_documentsAndEditors
:
ExtHostDocumentsAndEditors
,
...
...
@@ -240,6 +242,7 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
}
dispose
()
{
this
.
_disposed
=
true
;
super
.
dispose
();
this
.
_cellDisposableMapping
.
forEach
(
cell
=>
cell
.
dispose
());
}
...
...
@@ -265,6 +268,10 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
}
private
$spliceNotebookCells
(
splices
:
NotebookCellsSplice2
[]):
void
{
if
(
this
.
_disposed
)
{
return
;
}
if
(
!
splices
.
length
)
{
return
;
}
...
...
@@ -1028,21 +1035,23 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
if
(
delta
.
removedDocuments
)
{
delta
.
removedDocuments
.
forEach
((
uri
)
=>
{
let
document
=
this
.
_documents
.
get
(
URI
.
revive
(
uri
).
toString
());
const
revivedUri
=
URI
.
revive
(
uri
);
const
revivedUriStr
=
revivedUri
.
toString
();
let
document
=
this
.
_documents
.
get
(
revivedUriStr
);
if
(
document
)
{
document
.
dispose
();
this
.
_documents
.
delete
(
URI
.
revive
(
uri
).
toString
()
);
this
.
_documents
.
delete
(
revivedUriStr
);
this
.
_onDidCloseNotebookDocument
.
fire
(
document
);
}
let
editor
=
this
.
_editors
.
get
(
URI
.
revive
(
uri
).
toString
());
if
(
editor
)
{
editor
.
editor
.
dispose
();
editor
.
onDidReceiveMessage
.
dispose
(
);
this
.
_editors
.
delete
(
URI
.
revive
(
uri
).
toString
());
}
[...
this
.
_editors
.
values
()].
forEach
((
e
)
=>
{
if
(
e
.
editor
.
uri
.
toString
()
===
revivedUriStr
)
{
e
.
editor
.
dispose
();
e
.
onDidReceiveMessage
.
dispose
();
this
.
_editors
.
delete
(
e
.
editor
.
id
);
}
}
);
});
}
...
...
@@ -1073,6 +1082,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
]
});
this
.
_documents
.
get
(
revivedUriStr
)?.
dispose
();
this
.
_documents
.
set
(
revivedUriStr
,
document
);
// create editor if populated
...
...
@@ -1103,6 +1113,8 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
});
}
const
removedEditors
:
{
editor
:
ExtHostNotebookEditor
,
onDidReceiveMessage
:
Emitter
<
any
>
;
}[]
=
[];
if
(
delta
.
removedEditors
)
{
delta
.
removedEditors
.
forEach
(
editorid
=>
{
const
editor
=
this
.
_editors
.
get
(
editorid
);
...
...
@@ -1111,7 +1123,12 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
editorChanged
=
true
;
this
.
_editors
.
delete
(
editorid
);
// TODO, dispose the editor
if
(
this
.
activeNotebookEditor
?.
id
===
editor
.
editor
.
id
)
{
this
.
_activeNotebookEditor
=
undefined
;
this
.
_activeNotebookDocument
=
undefined
;
}
removedEditors
.
push
(
editor
);
}
});
}
...
...
@@ -1119,12 +1136,17 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
if
(
editorChanged
)
{
this
.
visibleNotebookEditors
=
[...
this
.
_editors
.
values
()].
map
(
e
=>
e
.
editor
);
this
.
_onDidChangeVisibleNotebookEditors
.
fire
(
this
.
visibleNotebookEditors
);
removedEditors
.
forEach
(
e
=>
{
e
.
editor
.
dispose
();
e
.
onDidReceiveMessage
.
dispose
();
});
}
if
(
delta
.
newActiveEditor
!==
undefined
)
{
if
(
delta
.
newActiveEditor
)
{
this
.
_activeNotebookEditor
=
this
.
_editors
.
get
(
delta
.
newActiveEditor
)?.
editor
;
this
.
_activeNotebookDocument
=
this
.
_
documents
.
get
(
this
.
_activeNotebookEditor
!
.
uri
.
toString
())
;
this
.
_activeNotebookDocument
=
this
.
_
activeNotebookEditor
?
this
.
_documents
.
get
(
this
.
_activeNotebookEditor
!
.
uri
.
toString
())
:
undefined
;
}
else
{
this
.
_activeNotebookEditor
=
undefined
;
this
.
_activeNotebookDocument
=
undefined
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录