Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cf5dfe1b
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,发现更多精彩内容 >>
提交
cf5dfe1b
编写于
8月 24, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unit test for applying metadata and output,
https://github.com/microsoft/vscode/issues/105283
上级
88664e26
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
97 addition
and
4 deletion
+97
-4
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+2
-0
src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts
...workbench/contrib/notebook/test/notebookTextModel.test.ts
+86
-1
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
+9
-3
未找到文件。
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
cf5dfe1b
...
...
@@ -252,10 +252,12 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
break
;
case
CellEditType
.
Output
:
//TODO@joh,@rebornix no event, no undo stop (?)
this
.
assertIndex
(
edit
.
index
);
const
cell
=
this
.
cells
[
edit
.
index
];
this
.
spliceNotebookCellOutputs
(
cell
.
handle
,
[[
0
,
cell
.
outputs
.
length
,
edit
.
outputs
]]);
break
;
case
CellEditType
.
Metadata
:
this
.
assertIndex
(
edit
.
index
);
this
.
changeCellMetadata
(
this
.
cells
[
edit
.
index
].
handle
,
edit
.
metadata
);
break
;
}
...
...
src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts
浏览文件 @
cf5dfe1b
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
CellKind
,
CellEditType
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
CellEditType
,
CellOutputKind
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
withTestNotebook
,
TestCell
,
setupInstantiationService
}
from
'
vs/workbench/contrib/notebook/test/testNotebookEditor
'
;
import
{
IBulkEditService
}
from
'
vs/editor/browser/services/bulkEditService
'
;
import
{
IUndoRedoService
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
...
...
@@ -139,4 +139,89 @@ suite('NotebookTextModel', () => {
}
);
});
test
(
'
output
'
,
function
()
{
withTestNotebook
(
instantiationService
,
blukEditService
,
undoRedoService
,
[
[
'
var a = 1;
'
,
'
javascript
'
,
CellKind
.
Code
,
[],
{
editable
:
true
}],
],
(
editor
,
viewModel
,
textModel
)
=>
{
// invalid index 1
assert
.
throws
(()
=>
{
textModel
.
applyEdit
(
textModel
.
versionId
,
[{
index
:
Number
.
MAX_VALUE
,
editType
:
CellEditType
.
Output
,
outputs
:
[]
}],
true
);
});
// invalid index 2
assert
.
throws
(()
=>
{
textModel
.
applyEdit
(
textModel
.
versionId
,
[{
index
:
-
1
,
editType
:
CellEditType
.
Output
,
outputs
:
[]
}],
true
);
});
textModel
.
applyEdit
(
textModel
.
versionId
,
[{
index
:
0
,
editType
:
CellEditType
.
Output
,
outputs
:
[{
outputKind
:
CellOutputKind
.
Rich
,
outputId
:
'
someId
'
,
data
:
{
'
text/markdown
'
:
'
_Hello_
'
}
}]
}],
true
);
assert
.
equal
(
textModel
.
cells
.
length
,
1
);
assert
.
equal
(
textModel
.
cells
[
0
].
outputs
.
length
,
1
);
assert
.
equal
(
textModel
.
cells
[
0
].
outputs
[
0
].
outputKind
,
CellOutputKind
.
Rich
);
}
);
});
test
(
'
metadata
'
,
function
()
{
withTestNotebook
(
instantiationService
,
blukEditService
,
undoRedoService
,
[
[
'
var a = 1;
'
,
'
javascript
'
,
CellKind
.
Code
,
[],
{
editable
:
true
}],
],
(
editor
,
viewModel
,
textModel
)
=>
{
// invalid index 1
assert
.
throws
(()
=>
{
textModel
.
applyEdit
(
textModel
.
versionId
,
[{
index
:
Number
.
MAX_VALUE
,
editType
:
CellEditType
.
Metadata
,
metadata
:
{
editable
:
false
}
}],
true
);
});
// invalid index 2
assert
.
throws
(()
=>
{
textModel
.
applyEdit
(
textModel
.
versionId
,
[{
index
:
-
1
,
editType
:
CellEditType
.
Metadata
,
metadata
:
{
editable
:
false
}
}],
true
);
});
textModel
.
applyEdit
(
textModel
.
versionId
,
[{
index
:
0
,
editType
:
CellEditType
.
Metadata
,
metadata
:
{
editable
:
false
},
}],
true
);
assert
.
equal
(
textModel
.
cells
.
length
,
1
);
assert
.
equal
(
textModel
.
cells
[
0
].
metadata
?.
editable
,
false
);
}
);
});
});
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
浏览文件 @
cf5dfe1b
...
...
@@ -381,9 +381,15 @@ export function withTestNotebook(instantiationService: TestInstantiationService,
const
viewType
=
'
notebook
'
;
const
editor
=
new
TestNotebookEditor
();
const
notebook
=
new
NotebookTextModel
(
0
,
viewType
,
false
,
URI
.
parse
(
'
test
'
),
undoRedoService
,
textModelService
);
notebook
.
cells
=
cells
.
map
((
cell
,
index
)
=>
{
return
new
NotebookCellTextModel
(
notebook
.
uri
,
index
,
cell
[
0
],
cell
[
1
],
cell
[
2
],
cell
[
3
],
cell
[
4
],
textModelService
);
});
notebook
.
initialize
(
cells
.
map
(
cell
=>
{
return
{
source
:
cell
[
0
],
language
:
cell
[
1
],
cellKind
:
cell
[
2
],
outputs
:
cell
[
3
],
metadata
:
cell
[
4
]
};
}));
const
model
=
new
NotebookEditorTestModel
(
notebook
);
const
eventDispatcher
=
new
NotebookEventDispatcher
();
const
viewModel
=
new
NotebookViewModel
(
viewType
,
model
.
notebook
,
eventDispatcher
,
null
,
instantiationService
,
blukEditService
,
undoRedoService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录