Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6c9398c3
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6c9398c3
编写于
4月 23, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clear cell output in the core
上级
e0a4eec7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
129 addition
and
3 deletion
+129
-3
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+13
-0
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
...workbench/contrib/notebook/browser/contrib/coreActions.ts
+70
-0
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+9
-1
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+22
-0
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+15
-2
未找到文件。
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
6c9398c3
...
...
@@ -251,6 +251,10 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
this
.
$spliceNotebookCells
(
event
.
changes
);
}
else
if
(
event
.
kind
===
NotebookCellsChangeType
.
Move
)
{
this
.
$moveCell
(
event
.
index
,
event
.
newIdx
);
}
else
if
(
event
.
kind
===
NotebookCellsChangeType
.
CellClearOutput
)
{
this
.
$clearCellOutputs
(
event
.
index
);
}
else
if
(
event
.
kind
===
NotebookCellsChangeType
.
CellsClearOutput
)
{
this
.
$clearAllCellOutputs
();
}
this
.
_versionId
=
event
.
versionId
;
...
...
@@ -299,6 +303,15 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
this
.
cells
.
splice
(
newIdx
,
0
,
...
cells
);
}
private
$clearCellOutputs
(
index
:
number
)
{
const
cell
=
this
.
cells
[
index
];
cell
.
outputs
=
[];
}
private
$clearAllCellOutputs
()
{
this
.
cells
.
forEach
(
cell
=>
cell
.
outputs
=
[]);
}
eventuallyUpdateCellOutputs
(
cell
:
ExtHostCell
,
diffs
:
ISplice
<
vscode
.
CellOutput
>
[])
{
let
renderers
=
new
Set
<
number
>
();
let
outputDtos
:
NotebookCellOutputsSplice
[]
=
diffs
.
map
(
diff
=>
{
...
...
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
浏览文件 @
6c9398c3
...
...
@@ -41,6 +41,9 @@ const CANCEL_CELL_COMMAND_ID = 'workbench.notebook.cell.cancelExecution';
const
EXECUTE_NOTEBOOK_COMMAND_ID
=
'
workbench.notebook.executeNotebook
'
;
const
CANCEL_NOTEBOOK_COMMAND_ID
=
'
workbench.notebook.cancelExecution
'
;
const
CLEAR_CELL_OUTPUTS_COMMAND_ID
=
'
workbench.action.notebook.clearCellOutputs
'
;
const
CLEAR_ALL_CELLS_OUTPUTS_COMMAND_ID
=
'
workbench.action.notebook.clearAllCellsOutputs
'
;
const
NOTEBOOK_ACTIONS_CATEGORY
=
localize
(
'
notebookActions.category
'
,
"
Notebook
"
);
const
EDITOR_WIDGET_ACTION_WEIGHT
=
KeybindingWeight
.
EditorContrib
;
// smaller than Suggest Widget, etc
...
...
@@ -50,6 +53,7 @@ const enum CellToolbarOrder {
MoveCellDown
,
EditCell
,
SaveCell
,
ClearCellOutput
,
InsertCell
,
DeleteCell
}
...
...
@@ -1171,3 +1175,69 @@ registerAction2(class extends Action2 {
editor
.
focusNotebookCell
(
firstCell
,
false
);
}
});
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
CLEAR_CELL_OUTPUTS_COMMAND_ID
,
title
:
'
Notebook Clear Active Cell Outputs
'
,
menu
:
{
id
:
MenuId
.
NotebookCellTitle
,
when
:
ContextKeyExpr
.
and
(
NOTEBOOK_CELL_TYPE
.
isEqualTo
(
'
code
'
),
NOTEBOOK_EDITOR_RUNNABLE
),
order
:
CellToolbarOrder
.
ClearCellOutput
},
icon
:
{
id
:
'
codicon/clear-all
'
},
f1
:
true
});
}
async
run
(
accessor
:
ServicesAccessor
,
context
?:
INotebookCellActionContext
):
Promise
<
void
>
{
if
(
!
isCellActionContext
(
context
))
{
context
=
getActiveCellContext
(
accessor
);
if
(
!
context
)
{
return
;
}
}
const
editor
=
context
.
notebookEditor
;
if
(
!
editor
.
viewModel
||
!
editor
.
viewModel
.
length
)
{
return
;
}
editor
.
viewModel
.
notebookDocument
.
clearCellOutput
(
context
.
cell
.
handle
);
}
});
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
CLEAR_ALL_CELLS_OUTPUTS_COMMAND_ID
,
title
:
'
Notebook Clear All Cells Outputs
'
,
menu
:
{
id
:
MenuId
.
EditorTitle
,
when
:
NOTEBOOK_EDITOR_FOCUSED
,
group
:
'
navigation
'
,
order
:
0
},
icon
:
{
id
:
'
codicon/clear-all
'
},
f1
:
true
});
}
async
run
(
accessor
:
ServicesAccessor
,
context
?:
INotebookCellActionContext
):
Promise
<
void
>
{
if
(
!
isCellActionContext
(
context
))
{
context
=
getActiveCellContext
(
accessor
);
if
(
!
context
)
{
return
;
}
}
const
editor
=
context
.
notebookEditor
;
if
(
!
editor
.
viewModel
||
!
editor
.
viewModel
.
length
)
{
return
;
}
editor
.
viewModel
.
notebookDocument
.
clearAllCellOutputs
();
}
});
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
6c9398c3
...
...
@@ -466,9 +466,10 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
const
scrollTop
=
this
.
list
?.
scrollTop
||
0
;
const
scrollHeight
=
this
.
list
?.
scrollHeight
||
0
;
this
.
webview
!
.
element
.
style
.
height
=
`
${
scrollHeight
}
px`
;
let
updateItems
:
{
cell
:
CodeCellViewModel
,
output
:
IOutput
,
cellTop
:
number
}[]
=
[];
if
(
this
.
webview
?.
insetMapping
)
{
let
updateItems
:
{
cell
:
CodeCellViewModel
,
output
:
IOutput
,
cellTop
:
number
}[]
=
[];
let
removedItems
:
IOutput
[]
=
[];
this
.
webview
?.
insetMapping
.
forEach
((
value
,
key
)
=>
{
const
cell
=
value
.
cell
;
const
viewIndex
=
this
.
list
?.
getViewIndex
(
cell
);
...
...
@@ -477,6 +478,11 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
return
;
}
if
(
cell
.
outputs
.
indexOf
(
key
)
<
0
)
{
// output is already gone
removedItems
.
push
(
key
);
}
const
cellTop
=
this
.
list
?.
getAbsoluteTopOfElement
(
cell
)
||
0
;
if
(
this
.
webview
!
.
shouldUpdateInset
(
cell
,
key
,
cellTop
))
{
updateItems
.
push
({
...
...
@@ -487,6 +493,8 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
}
});
removedItems
.
forEach
(
output
=>
this
.
webview
?.
removeInset
(
output
));
if
(
updateItems
.
length
)
{
this
.
webview
?.
updateViewScrollTop
(
-
scrollTop
,
updateItems
);
}
...
...
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
6c9398c3
...
...
@@ -286,6 +286,28 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
cell
?.
spliceNotebookCellOutputs
(
splices
);
}
clearCellOutput
(
handle
:
number
)
{
let
cell
=
this
.
_mapping
.
get
(
handle
);
if
(
cell
)
{
cell
.
spliceNotebookCellOutputs
([
[
0
,
cell
.
outputs
.
length
,
[]]
]);
this
.
_increaseVersionId
();
this
.
_onDidModelChangeProxy
.
fire
({
kind
:
NotebookCellsChangeType
.
CellClearOutput
,
versionId
:
this
.
_versionId
,
index
:
this
.
cells
.
indexOf
(
cell
)
});
}
}
clearAllCellOutputs
()
{
this
.
cells
.
forEach
(
cell
=>
{
cell
.
spliceNotebookCellOutputs
([
[
0
,
cell
.
outputs
.
length
,
[]]
]);
});
this
.
_increaseVersionId
();
this
.
_onDidModelChangeProxy
.
fire
({
kind
:
NotebookCellsChangeType
.
CellsClearOutput
,
versionId
:
this
.
_versionId
});
}
dispose
()
{
this
.
_onWillDispose
.
fire
();
this
.
_cellListeners
.
forEach
(
val
=>
val
.
dispose
());
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
6c9398c3
...
...
@@ -219,7 +219,9 @@ export type NotebookCellsSplice2 = [
export
enum
NotebookCellsChangeType
{
ModelChange
=
1
,
Move
=
2
Move
=
2
,
CellClearOutput
=
3
,
CellsClearOutput
=
4
}
export
interface
NotebookCellsModelChangedEvent
{
...
...
@@ -235,7 +237,18 @@ export interface NotebookCellsModelMoveEvent {
readonly
versionId
:
number
;
}
export
type
NotebookCellsChangedEvent
=
NotebookCellsModelChangedEvent
|
NotebookCellsModelMoveEvent
;
export
interface
NotebookCellClearOutputEvent
{
readonly
kind
:
NotebookCellsChangeType
.
CellClearOutput
;
readonly
index
:
number
;
readonly
versionId
:
number
;
}
export
interface
NotebookCellsClearOutputEvent
{
readonly
kind
:
NotebookCellsChangeType
.
CellsClearOutput
;
readonly
versionId
:
number
;
}
export
type
NotebookCellsChangedEvent
=
NotebookCellsModelChangedEvent
|
NotebookCellsModelMoveEvent
|
NotebookCellClearOutputEvent
|
NotebookCellsClearOutputEvent
;
export
enum
CellEditType
{
Insert
=
1
,
Delete
=
2
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录