Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b2ecde87
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,发现更多精彩内容 >>
提交
b2ecde87
编写于
4月 21, 2020
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix elements being disposed after rendering
上级
647e0bea
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
19 addition
and
27 deletion
+19
-27
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+1
-0
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+18
-27
未找到文件。
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
b2ecde87
...
...
@@ -358,6 +358,7 @@ export interface BaseCellRenderTemplate {
focusIndicator
:
HTMLElement
;
insertionIndicatorTop
:
HTMLElement
;
disposables
:
DisposableStore
;
elementDisposables
:
DisposableStore
;
bottomCellContainer
:
HTMLElement
;
currentRenderedCell
?:
ICellViewModel
;
toJSON
:
()
=>
any
;
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
b2ecde87
...
...
@@ -269,7 +269,6 @@ abstract class AbstractCellRenderer {
export
class
MarkdownCellRenderer
extends
AbstractCellRenderer
implements
IListRenderer
<
MarkdownCellViewModel
,
MarkdownCellRenderTemplate
>
{
static
readonly
TEMPLATE_ID
=
'
markdown_cell
'
;
private
disposables
:
Map
<
ICellViewModel
,
DisposableStore
>
=
new
Map
();
constructor
(
contextKeyService
:
IContextKeyService
,
...
...
@@ -318,6 +317,7 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
focusIndicator
,
foldingIndicator
,
disposables
,
elementDisposables
:
new
DisposableStore
(),
toolbar
,
bottomCellContainer
,
toJSON
:
()
=>
{
return
{};
}
...
...
@@ -345,13 +345,9 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
}
if
(
height
)
{
this
.
disposables
.
get
(
element
)?.
clear
();
if
(
!
this
.
disposables
.
has
(
element
))
{
this
.
disposables
.
set
(
element
,
new
DisposableStore
());
}
const
elementDisposable
=
this
.
disposables
.
get
(
element
)
!
;
const
elementDisposables
=
templateData
.
elementDisposables
;
elementDisposable
.
add
(
new
StatefullMarkdownCell
(
this
.
notebookEditor
,
element
,
templateData
,
this
.
editorOptions
,
this
.
instantiationService
));
elementDisposable
s
.
add
(
new
StatefullMarkdownCell
(
this
.
notebookEditor
,
element
,
templateData
,
this
.
editorOptions
,
this
.
instantiationService
));
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
markdown
'
);
...
...
@@ -365,20 +361,20 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
};
updateForMetadata
();
elementDisposable
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
elementDisposable
s
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
if
(
e
.
metadataChanged
)
{
updateForMetadata
();
}
}));
const
editModeKey
=
contextKeyService
.
createKey
(
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY
,
element
.
editState
===
CellEditState
.
Editing
);
elementDisposable
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
elementDisposable
s
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
if
(
e
.
editStateChanged
)
{
editModeKey
.
set
(
element
.
editState
===
CellEditState
.
Editing
);
}
}));
this
.
setupCellToolbarActions
(
contextKeyService
,
templateData
,
elementDisposable
);
this
.
setupCellToolbarActions
(
contextKeyService
,
templateData
,
elementDisposable
s
);
const
toolbarContext
=
<
INotebookCellActionContext
>
{
cell
:
element
,
...
...
@@ -387,7 +383,7 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
};
templateData
.
toolbar
.
context
=
toolbarContext
;
this
.
setupBetweenCellToolbarActions
(
element
,
templateData
,
elementDisposable
,
toolbarContext
);
this
.
setupBetweenCellToolbarActions
(
element
,
templateData
,
elementDisposable
s
,
toolbarContext
);
element
.
totalHeight
=
height
;
}
...
...
@@ -399,7 +395,7 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
disposeElement
(
element
:
ICellViewModel
,
index
:
number
,
templateData
:
MarkdownCellRenderTemplate
,
height
:
number
|
undefined
):
void
{
if
(
height
)
{
t
his
.
disposables
.
get
(
element
)?
.
clear
();
t
emplateData
.
elementDisposables
.
clear
();
}
}
}
...
...
@@ -584,7 +580,6 @@ class CodeCellDragImageRenderer {
export
class
CodeCellRenderer
extends
AbstractCellRenderer
implements
IListRenderer
<
CodeCellViewModel
,
CodeCellRenderTemplate
>
{
static
readonly
TEMPLATE_ID
=
'
code_cell
'
;
private
disposables
:
Map
<
ICellViewModel
,
DisposableStore
>
=
new
Map
();
constructor
(
protected
notebookEditor
:
INotebookEditor
,
...
...
@@ -662,7 +657,8 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
outputContainer
,
editor
,
disposables
,
bottomCellContainer
:
bottomCellContainer
,
elementDisposables
:
new
DisposableStore
(),
bottomCellContainer
,
toJSON
:
()
=>
{
return
{};
}
};
...
...
@@ -735,18 +731,13 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
templateData
.
outputContainer
.
innerHTML
=
''
;
this
.
disposables
.
get
(
element
)?.
clear
();
if
(
!
this
.
disposables
.
has
(
element
))
{
this
.
disposables
.
set
(
element
,
new
DisposableStore
());
}
const
elementDisposable
=
this
.
disposables
.
get
(
element
)
!
;
const
elementDisposables
=
templateData
.
elementDisposables
;
elementDisposable
.
add
(
this
.
instantiationService
.
createInstance
(
CodeCell
,
this
.
notebookEditor
,
element
,
templateData
));
elementDisposable
s
.
add
(
this
.
instantiationService
.
createInstance
(
CodeCell
,
this
.
notebookEditor
,
element
,
templateData
));
this
.
renderedEditors
.
set
(
element
,
templateData
.
editor
);
templateData
.
focusIndicator
.
style
.
height
=
`
${
element
.
layoutInfo
.
indicatorHeight
}
px`
;
elementDisposable
.
add
(
element
.
onDidChangeLayout
(()
=>
{
elementDisposable
s
.
add
(
element
.
onDidChangeLayout
(()
=>
{
templateData
.
focusIndicator
.
style
.
height
=
`
${
element
.
layoutInfo
.
indicatorHeight
}
px`
;
}));
...
...
@@ -754,7 +745,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
const
runStateKey
=
contextKeyService
.
createKey
(
NOTEBOOK_CELL_RUN_STATE_CONTEXT_KEY
,
CellRunState
[
element
.
runState
]);
this
.
updateForRunState
(
element
,
templateData
,
runStateKey
);
elementDisposable
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
elementDisposable
s
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
if
(
e
.
runStateChanged
)
{
this
.
updateForRunState
(
element
,
templateData
,
runStateKey
);
}
...
...
@@ -765,13 +756,13 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
const
metadata
=
element
.
getEvaluatedMetadata
(
this
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
metadata
);
const
cellEditableKey
=
contextKeyService
.
createKey
(
NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY
,
!!
metadata
.
editable
);
this
.
updateForMetadata
(
element
,
templateData
,
cellEditableKey
);
elementDisposable
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
elementDisposable
s
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
if
(
e
.
metadataChanged
)
{
this
.
updateForMetadata
(
element
,
templateData
,
cellEditableKey
);
}
}));
this
.
setupCellToolbarActions
(
contextKeyService
,
templateData
,
elementDisposable
);
this
.
setupCellToolbarActions
(
contextKeyService
,
templateData
,
elementDisposable
s
);
const
toolbarContext
=
<
INotebookCellActionContext
>
{
cell
:
element
,
...
...
@@ -782,7 +773,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
templateData
.
toolbar
.
context
=
toolbarContext
;
templateData
.
runToolbar
.
context
=
toolbarContext
;
this
.
setupBetweenCellToolbarActions
(
element
,
templateData
,
elementDisposable
,
toolbarContext
);
this
.
setupBetweenCellToolbarActions
(
element
,
templateData
,
elementDisposable
s
,
toolbarContext
);
}
disposeTemplate
(
templateData
:
CodeCellRenderTemplate
):
void
{
...
...
@@ -790,7 +781,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
}
disposeElement
(
element
:
ICellViewModel
,
index
:
number
,
templateData
:
CodeCellRenderTemplate
,
height
:
number
|
undefined
):
void
{
t
his
.
disposables
.
get
(
element
)?
.
clear
();
t
emplateData
.
elementDisposables
.
clear
();
this
.
renderedEditors
.
delete
(
element
);
templateData
.
focusIndicator
.
style
.
height
=
'
initial
'
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录