Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
03fdd53f
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,发现更多精彩内容 >>
提交
03fdd53f
编写于
2月 05, 2021
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
append/replace output items
上级
008e5c73
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
94 addition
and
5 deletion
+94
-5
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+2
-2
src/vs/workbench/api/common/extHostTypeConverters.ts
src/vs/workbench/api/common/extHostTypeConverters.ts
+12
-0
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+24
-1
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+45
-0
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+11
-2
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
03fdd53f
...
...
@@ -1502,8 +1502,8 @@ declare module 'vscode' {
// TODO@api
// https://jupyter-protocol.readthedocs.io/en/latest/messaging.html#update-display-data
// replaceNotebookCellOutput(uri: Uri, index: number, outputId:string, outputs: NotebookCellOutput
[], metadata?: WorkspaceEditEntryMetadata): void;
// appendNotebookCellOutput(uri: Uri, index: number, outputId:string, outputs: NotebookCellOutput
[], metadata?: WorkspaceEditEntryMetadata): void;
replaceNotebookCellOutputItems
(
uri
:
Uri
,
index
:
number
,
outputId
:
string
,
items
:
NotebookCellOutputItem
[],
metadata
?:
WorkspaceEditEntryMetadata
):
void
;
appendNotebookCellOutputItems
(
uri
:
Uri
,
index
:
number
,
outputId
:
string
,
items
:
NotebookCellOutputItem
[],
metadata
?:
WorkspaceEditEntryMetadata
):
void
;
}
export
interface
NotebookEditorEdit
{
...
...
src/vs/workbench/api/common/extHostTypeConverters.ts
浏览文件 @
03fdd53f
...
...
@@ -587,6 +587,18 @@ export namespace WorkspaceEdit {
cells
:
entry
.
cells
.
map
(
NotebookCellData
.
from
)
}
});
}
else
if
(
entry
.
_type
===
types
.
FileEditType
.
CellOutputItem
)
{
result
.
edits
.
push
({
_type
:
extHostProtocol
.
WorkspaceEditType
.
Cell
,
metadata
:
entry
.
metadata
,
resource
:
entry
.
uri
,
edit
:
{
editType
:
CellEditType
.
OutputItems
,
index
:
entry
.
index
,
outputId
:
entry
.
outputId
,
data
:
entry
.
newOutputItems
?
entry
.
newOutputItems
.
reduce
((
a
,
x
)
=>
({
...
a
,
[
x
.
mime
]:
x
.
value
}),
{})
:
[]
}
});
}
}
}
...
...
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
03fdd53f
...
...
@@ -588,6 +588,7 @@ export const enum FileEditType {
Cell
=
3
,
CellOutput
=
4
,
CellReplace
=
5
,
CellOutputItem
=
6
}
export
interface
IFileOperation
{
...
...
@@ -632,8 +633,18 @@ export interface ICellOutputEdit {
metadata
?:
vscode
.
WorkspaceEditEntryMetadata
;
}
export
interface
ICellOutputItemsEdit
{
_type
:
FileEditType
.
CellOutputItem
;
uri
:
URI
;
index
:
number
;
outputId
:
string
;
append
:
boolean
;
newOutputItems
?:
NotebookCellOutputItem
[];
metadata
?:
vscode
.
WorkspaceEditEntryMetadata
;
}
type
WorkspaceEditEntry
=
IFileOperation
|
IFileTextEdit
|
IFileCellEdit
|
ICellEdit
|
ICellOutputEdit
;
type
WorkspaceEditEntry
=
IFileOperation
|
IFileTextEdit
|
IFileCellEdit
|
ICellEdit
|
ICellOutputEdit
|
ICellOutputItemsEdit
;
@
es5ClassCompat
export
class
WorkspaceEdit
implements
vscode
.
WorkspaceEdit
{
...
...
@@ -679,6 +690,18 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
this
.
_editNotebookCellOutput
(
uri
,
index
,
true
,
outputs
,
metadata
);
}
replaceNotebookCellOutputItems
(
uri
:
URI
,
index
:
number
,
outputId
:
string
,
items
:
NotebookCellOutputItem
[],
metadata
?:
vscode
.
WorkspaceEditEntryMetadata
):
void
{
this
.
_editNotebookCellOutputItems
(
uri
,
index
,
outputId
,
false
,
items
,
metadata
);
}
appendNotebookCellOutputItems
(
uri
:
URI
,
index
:
number
,
outputId
:
string
,
items
:
NotebookCellOutputItem
[],
metadata
?:
vscode
.
WorkspaceEditEntryMetadata
):
void
{
this
.
_editNotebookCellOutputItems
(
uri
,
index
,
outputId
,
true
,
items
,
metadata
);
}
private
_editNotebookCellOutputItems
(
uri
:
URI
,
index
:
number
,
id
:
string
,
append
:
boolean
,
items
:
vscode
.
NotebookCellOutputItem
[],
metadata
:
vscode
.
WorkspaceEditEntryMetadata
|
undefined
):
void
{
this
.
_edits
.
push
({
_type
:
FileEditType
.
CellOutputItem
,
metadata
,
uri
,
index
,
outputId
:
id
,
append
,
newOutputItems
:
items
});
}
private
_editNotebookCellOutput
(
uri
:
URI
,
index
:
number
,
append
:
boolean
,
outputs
:
(
vscode
.
NotebookCellOutput
|
vscode
.
CellOutput
)[],
metadata
:
vscode
.
WorkspaceEditEntryMetadata
|
undefined
):
void
{
let
newOutputs
:
NotebookCellOutput
[];
const
[
first
]
=
outputs
;
...
...
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
03fdd53f
...
...
@@ -345,6 +345,17 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this
.
_spliceNotebookCellOutputs2
(
cell
.
handle
,
edit
.
outputs
,
computeUndoRedo
);
}
break
;
case
CellEditType
.
OutputItems
:
{
this
.
_assertIndex
(
edit
.
index
);
const
cell
=
this
.
_cells
[
edit
.
index
];
if
(
edit
.
append
)
{
this
.
_appendNotebookCellOutputItems
(
cell
.
handle
,
edit
.
outputId
,
edit
.
data
);
}
else
{
this
.
_replaceNotebookCellOutputItems
(
cell
.
handle
,
edit
.
outputId
,
edit
.
data
);
}
}
break
;
case
CellEditType
.
OutputsSplice
:
{
//TODO@jrieken,@rebornix no event, no undo stop (?)
...
...
@@ -675,6 +686,40 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
}
}
private
_appendNotebookCellOutputItems
(
cellHandle
:
number
,
outputId
:
string
,
data
:
{
[
key
:
string
]:
any
})
{
const
cell
=
this
.
_mapping
.
get
(
cellHandle
);
if
(
!
cell
)
{
return
;
}
const
outputIndex
=
cell
.
outputs
.
findIndex
(
output
=>
output
.
outputId
===
outputId
);
if
(
outputIndex
<
0
)
{
return
;
}
const
output
=
cell
.
outputs
[
outputIndex
];
output
.
data
=
data
;
cell
.
spliceNotebookCellOutputs
([[
outputIndex
,
1
,
[
output
]]]);
}
private
_replaceNotebookCellOutputItems
(
cellHandle
:
number
,
outputId
:
string
,
data
:
{
[
key
:
string
]:
any
})
{
const
cell
=
this
.
_mapping
.
get
(
cellHandle
);
if
(
!
cell
)
{
return
;
}
const
outputIndex
=
cell
.
outputs
.
findIndex
(
output
=>
output
.
outputId
===
outputId
);
if
(
outputIndex
<
0
)
{
return
;
}
const
output
=
cell
.
outputs
[
outputIndex
];
output
.
data
=
data
;
cell
.
spliceNotebookCellOutputs
([[
outputIndex
,
1
,
[
output
]]]);
}
private
_moveCellToIdx
(
index
:
number
,
length
:
number
,
newIdx
:
number
,
synchronous
:
boolean
,
pushedToUndoStack
:
boolean
,
beforeSelections
:
number
[]
|
undefined
,
endSelections
:
number
[]
|
undefined
):
boolean
{
if
(
pushedToUndoStack
)
{
this
.
_operationManager
.
pushEditOperation
(
new
MoveCellEdit
(
this
.
uri
,
index
,
length
,
newIdx
,
{
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
03fdd53f
...
...
@@ -303,7 +303,8 @@ export const enum CellEditType {
OutputsSplice
=
6
,
Move
=
7
,
Unknown
=
8
,
CellContent
=
9
CellContent
=
9
,
OutputItems
=
10
}
export
interface
ICellDto2
{
...
...
@@ -328,6 +329,14 @@ export interface ICellOutputEdit {
append
?:
boolean
}
export
interface
ICellOutputItemEdit
{
editType
:
CellEditType
.
OutputItems
;
index
:
number
;
outputId
:
string
;
data
:
{
[
key
:
string
]:
unknown
;
}
append
?:
boolean
;
}
export
interface
ICellMetadataEdit
{
editType
:
CellEditType
.
Metadata
;
index
:
number
;
...
...
@@ -359,7 +368,7 @@ export interface ICellMoveEdit {
newIdx
:
number
;
}
export
type
ICellEditOperation
=
ICellReplaceEdit
|
ICellOutputEdit
|
ICellMetadataEdit
|
ICellLanguageEdit
|
IDocumentMetadataEdit
|
ICellOutputsSpliceEdit
|
ICellMoveEdit
;
export
type
ICellEditOperation
=
ICellReplaceEdit
|
ICellOutputEdit
|
ICellMetadataEdit
|
ICellLanguageEdit
|
IDocumentMetadataEdit
|
ICellOutputsSpliceEdit
|
ICellMoveEdit
|
ICellOutputItemEdit
;
export
interface
INotebookEditData
{
documentVersionId
:
number
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录