Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d8df542f
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,发现更多精彩内容 >>
提交
d8df542f
编写于
3月 09, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
track newly created view cell in notebookviewmodel
上级
69d2a45a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
11 addition
and
20 deletion
+11
-20
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+1
-2
src/vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel.ts
...ntrib/notebook/browser/viewModel/notebookCellViewModel.ts
+0
-9
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
...h/contrib/notebook/browser/viewModel/notebookViewModel.ts
+6
-2
src/vs/workbench/contrib/notebook/test/notebookViewModel.test.ts
...workbench/contrib/notebook/test/notebookViewModel.test.ts
+4
-7
未找到文件。
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
d8df542f
...
@@ -507,9 +507,8 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
...
@@ -507,9 +507,8 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
const
index
=
this
.
notebookViewModel
!
.
getViewCellIndex
(
cell
);
const
index
=
this
.
notebookViewModel
!
.
getViewCellIndex
(
cell
);
const
insertIndex
=
direction
===
'
above
'
?
index
:
index
+
1
;
const
insertIndex
=
direction
===
'
above
'
?
index
:
index
+
1
;
const
newModeCell
=
await
this
.
notebookService
.
createNotebookCell
(
this
.
viewType
!
,
this
.
notebookViewModel
!
.
uri
,
insertIndex
,
language
,
type
);
const
newModeCell
=
await
this
.
notebookService
.
createNotebookCell
(
this
.
viewType
!
,
this
.
notebookViewModel
!
.
uri
,
insertIndex
,
language
,
type
);
const
newCell
=
this
.
instantiationService
.
createInstance
(
CellViewModel
,
this
.
viewType
!
,
this
.
notebookViewModel
!
.
handle
,
newModeCell
!
);
const
newCell
=
this
.
notebookViewModel
!
.
insertCell
(
insertIndex
,
newModeCell
!
);
this
.
notebookViewModel
!
.
insertCell
(
insertIndex
,
newCell
);
this
.
list
?.
splice
(
insertIndex
,
0
,
[
newCell
]);
this
.
list
?.
splice
(
insertIndex
,
0
,
[
newCell
]);
this
.
list
?.
setFocus
([
insertIndex
]);
this
.
list
?.
setFocus
([
insertIndex
]);
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel.ts
浏览文件 @
d8df542f
...
@@ -153,15 +153,6 @@ export class CellViewModel extends Disposable {
...
@@ -153,15 +153,6 @@ export class CellViewModel extends Disposable {
};
};
}
}
stopFind
(
keepSelection
?:
boolean
|
undefined
):
void
{
if
(
!
this
.
assertTextModelAttached
())
{
return
;
}
}
focus
():
void
{
}
assertTextModelAttached
():
boolean
{
assertTextModelAttached
():
boolean
{
if
(
this
.
_textModel
&&
this
.
_textEditor
&&
this
.
_textEditor
.
getModel
()
===
this
.
_textModel
)
{
if
(
this
.
_textModel
&&
this
.
_textEditor
&&
this
.
_textEditor
.
getModel
()
===
this
.
_textModel
)
{
return
true
;
return
true
;
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
浏览文件 @
d8df542f
...
@@ -9,7 +9,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
...
@@ -9,7 +9,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
NotebookEditorModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookEditorInput
'
;
import
{
NotebookEditorModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookEditorInput
'
;
import
{
CellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel
'
;
import
{
CellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel
'
;
import
{
NotebookCellsSplice
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookCellsSplice
,
ICell
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
IModelDeltaDecoration
}
from
'
vs/editor/common/model
'
;
import
{
IModelDeltaDecoration
}
from
'
vs/editor/common/model
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
CellFindMatch
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellFindMatch
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
...
@@ -114,15 +114,19 @@ export class NotebookViewModel extends Disposable {
...
@@ -114,15 +114,19 @@ export class NotebookViewModel extends Disposable {
return
matches
;
return
matches
;
}
}
insertCell
(
index
:
number
,
newCell
:
CellViewModel
)
{
insertCell
(
index
:
number
,
cell
:
ICell
):
CellViewModel
{
const
newCell
=
this
.
instantiationService
.
createInstance
(
CellViewModel
,
this
.
viewType
,
this
.
handle
,
cell
);
this
.
viewCells
!
.
splice
(
index
,
0
,
newCell
);
this
.
viewCells
!
.
splice
(
index
,
0
,
newCell
);
this
.
_model
.
insertCell
(
newCell
.
cell
,
index
);
this
.
_model
.
insertCell
(
newCell
.
cell
,
index
);
this
.
_localStore
.
add
(
newCell
);
return
newCell
;
}
}
deleteCell
(
index
:
number
)
{
deleteCell
(
index
:
number
)
{
let
viewCell
=
this
.
viewCells
[
index
];
let
viewCell
=
this
.
viewCells
[
index
];
this
.
viewCells
.
splice
(
index
,
1
);
this
.
viewCells
.
splice
(
index
,
1
);
this
.
_model
.
deleteCell
(
viewCell
.
cell
);
this
.
_model
.
deleteCell
(
viewCell
.
cell
);
viewCell
.
dispose
();
}
}
saveEditorViewState
():
INotebookEditorViewState
{
saveEditorViewState
():
INotebookEditorViewState
{
...
...
src/vs/workbench/contrib/notebook/test/notebookViewModel.test.ts
浏览文件 @
d8df542f
...
@@ -9,7 +9,7 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
...
@@ -9,7 +9,7 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
import
{
NotebookEditorModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookEditorInput
'
;
import
{
NotebookEditorModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookEditorInput
'
;
import
{
NotebookViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
NotebookViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
CellKind
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
createTestCellViewModel
,
TestNotebook
,
withTestNotebook
}
from
'
vs/workbench/contrib/notebook/test/testNotebookEditor
'
;
import
{
TestNotebook
,
withTestNotebook
,
TestCell
}
from
'
vs/workbench/contrib/notebook/test/testNotebookEditor
'
;
suite
(
'
NotebookViewModel
'
,
()
=>
{
suite
(
'
NotebookViewModel
'
,
()
=>
{
const
instantiationService
=
new
TestInstantiationService
();
const
instantiationService
=
new
TestInstantiationService
();
...
@@ -29,8 +29,7 @@ suite('NotebookViewModel', () => {
...
@@ -29,8 +29,7 @@ suite('NotebookViewModel', () => {
[[
'
var b = 2;
'
],
'
javascript
'
,
CellKind
.
Code
,
[]]
[[
'
var b = 2;
'
],
'
javascript
'
,
CellKind
.
Code
,
[]]
],
],
(
editor
,
viewModel
)
=>
{
(
editor
,
viewModel
)
=>
{
const
cell
=
createTestCellViewModel
(
instantiationService
,
viewModel
.
viewType
,
viewModel
.
handle
,
0
,
[
'
var c = 3;
'
],
'
javascript
'
,
CellKind
.
Code
,
[]);
const
cell
=
viewModel
.
insertCell
(
1
,
new
TestCell
(
viewModel
.
viewType
,
0
,
[
'
var c = 3;
'
],
'
javascript
'
,
CellKind
.
Code
,
[]));
viewModel
.
insertCell
(
1
,
cell
);
assert
.
equal
(
viewModel
.
viewCells
.
length
,
3
);
assert
.
equal
(
viewModel
.
viewCells
.
length
,
3
);
assert
.
equal
(
viewModel
.
notebookDocument
.
cells
.
length
,
3
);
assert
.
equal
(
viewModel
.
notebookDocument
.
cells
.
length
,
3
);
assert
.
equal
(
viewModel
.
getViewCellIndex
(
cell
),
1
);
assert
.
equal
(
viewModel
.
getViewCellIndex
(
cell
),
1
);
...
@@ -55,15 +54,13 @@ suite('NotebookViewModel', () => {
...
@@ -55,15 +54,13 @@ suite('NotebookViewModel', () => {
const
lastViewCell
=
viewModel
.
viewCells
[
viewModel
.
viewCells
.
length
-
1
];
const
lastViewCell
=
viewModel
.
viewCells
[
viewModel
.
viewCells
.
length
-
1
];
const
insertIndex
=
viewModel
.
getViewCellIndex
(
firstViewCell
)
+
1
;
const
insertIndex
=
viewModel
.
getViewCellIndex
(
firstViewCell
)
+
1
;
const
cell
=
createTestCellViewModel
(
instantiationService
,
viewModel
.
viewType
,
viewModel
.
handle
,
3
,
[
'
var c = 3;
'
],
'
javascript
'
,
CellKind
.
Code
,
[]);
const
cell
=
viewModel
.
insertCell
(
insertIndex
,
new
TestCell
(
viewModel
.
viewType
,
3
,
[
'
var c = 3;
'
],
'
javascript
'
,
CellKind
.
Code
,
[]));
viewModel
.
insertCell
(
insertIndex
,
cell
);
const
addedCellIndex
=
viewModel
.
getViewCellIndex
(
cell
);
const
addedCellIndex
=
viewModel
.
getViewCellIndex
(
cell
);
viewModel
.
deleteCell
(
addedCellIndex
);
viewModel
.
deleteCell
(
addedCellIndex
);
const
secondInsertIndex
=
viewModel
.
getViewCellIndex
(
lastViewCell
)
+
1
;
const
secondInsertIndex
=
viewModel
.
getViewCellIndex
(
lastViewCell
)
+
1
;
const
cell2
=
createTestCellViewModel
(
instantiationService
,
viewModel
.
viewType
,
viewModel
.
handle
,
4
,
[
'
var d = 4;
'
],
'
javascript
'
,
CellKind
.
Code
,
[]);
const
cell2
=
viewModel
.
insertCell
(
secondInsertIndex
,
new
TestCell
(
viewModel
.
viewType
,
4
,
[
'
var d = 4;
'
],
'
javascript
'
,
CellKind
.
Code
,
[]));
viewModel
.
insertCell
(
secondInsertIndex
,
cell2
);
assert
.
equal
(
viewModel
.
viewCells
.
length
,
3
);
assert
.
equal
(
viewModel
.
viewCells
.
length
,
3
);
assert
.
equal
(
viewModel
.
notebookDocument
.
cells
.
length
,
3
);
assert
.
equal
(
viewModel
.
notebookDocument
.
cells
.
length
,
3
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录