Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b139c10f
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,发现更多精彩内容 >>
提交
b139c10f
编写于
3月 01, 2021
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add tests for notebook outline
上级
de020f04
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
107 addition
and
17 deletion
+107
-17
src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts
...b/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.ts
...ntrib/notebook/browser/contrib/outline/notebookOutline.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/contrib/outline/test/notebookOutline.test.ts
...book/browser/contrib/outline/test/notebookOutline.test.ts
+90
-0
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
+14
-14
src/vs/workbench/services/outline/browser/outline.ts
src/vs/workbench/services/outline/browser/outline.ts
+1
-1
未找到文件。
src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts
浏览文件 @
b139c10f
...
...
@@ -162,7 +162,7 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess
}
}));
const
entries
=
Array
.
from
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
()
);
const
entries
=
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
(
);
const
items
:
IGotoSymbolQuickPickItem
[]
=
entries
.
map
((
entry
,
idx
)
=>
{
return
{
...
...
src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.ts
浏览文件 @
b139c10f
...
...
@@ -237,7 +237,7 @@ class NotebookQuickPickProvider implements IQuickPickDataSource<OutlineEntry> {
@
IThemeService
private
readonly
_themeService
:
IThemeService
)
{
}
getQuickPickElements
():
I
terable
<
IQuickPickOutlineElement
<
OutlineEntry
>>
{
getQuickPickElements
():
I
QuickPickOutlineElement
<
OutlineEntry
>
[]
{
const
bucket
:
OutlineEntry
[]
=
[];
for
(
let
entry
of
this
.
_getEntries
())
{
entry
.
asFlatList
(
bucket
);
...
...
src/vs/workbench/contrib/notebook/browser/contrib/outline/test/notebookOutline.test.ts
0 → 100644
浏览文件 @
b139c10f
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
setupInstantiationService
,
withTestNotebook
}
from
'
vs/workbench/contrib/notebook/test/testNotebookEditor
'
;
import
{
IUndoRedoService
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
{
OutlineTarget
}
from
'
vs/workbench/services/outline/browser/outline
'
;
import
{
NotebookCellOutline
}
from
'
vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline
'
;
import
{
IFileIconTheme
,
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
mock
}
from
'
vs/base/test/common/mock
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IMarkerService
}
from
'
vs/platform/markers/common/markers
'
;
import
{
MarkerService
}
from
'
vs/platform/markers/common/markerService
'
;
import
{
CellKind
,
IOutputDto
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
IActiveNotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
suite
(
'
Notebook Outline
'
,
function
()
{
const
instantiationService
=
setupInstantiationService
();
instantiationService
.
spy
(
IUndoRedoService
,
'
pushElement
'
);
instantiationService
.
set
(
IEditorService
,
new
class
extends
mock
<
IEditorService
>
()
{
});
instantiationService
.
set
(
IMarkerService
,
new
MarkerService
());
instantiationService
.
set
(
IThemeService
,
new
class
extends
mock
<
IThemeService
>
()
{
onDidFileIconThemeChange
=
Event
.
None
;
getFileIconTheme
():
IFileIconTheme
{
return
{
hasFileIcons
:
true
,
hasFolderIcons
:
true
,
hidesExplorerArrows
:
false
};
}
});
function
withNotebookOutline
<
R
=
any
>
(
cells
:
[
source
:
string
,
lang
:
string
,
kind
:
CellKind
,
output
?:
IOutputDto
[],
metadata
?:
NotebookCellMetadata
][],
callback
:
(
outline
:
NotebookCellOutline
,
editor
:
IActiveNotebookEditor
)
=>
R
):
R
{
return
withTestNotebook
(
instantiationService
,
cells
,
(
editor
)
=>
{
if
(
!
editor
.
hasModel
())
{
assert
.
ok
(
false
,
'
MUST have active text editor
'
);
}
const
outline
=
instantiationService
.
createInstance
(
NotebookCellOutline
,
editor
,
OutlineTarget
.
OutlinePane
);
return
callback
(
outline
,
editor
);
});
}
test
(
'
basic
'
,
function
()
{
withNotebookOutline
([],
outline
=>
{
assert
.
ok
(
outline
instanceof
NotebookCellOutline
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
(),
[]);
});
});
test
(
'
special characters in heading
'
,
function
()
{
withNotebookOutline
([
[
'
# Hellö & Hällo
'
,
'
md
'
,
CellKind
.
Markdown
]
],
outline
=>
{
assert
.
ok
(
outline
instanceof
NotebookCellOutline
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
().
length
,
1
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
()[
0
].
label
,
'
Hellö & Hällo
'
);
});
});
test
(
'
First line vs heading...
'
,
function
()
{
return
withNotebookOutline
([
[
'
foo
\n
# h1
'
,
'
md
'
,
CellKind
.
Markdown
]
],
outline
=>
{
assert
.
ok
(
outline
instanceof
NotebookCellOutline
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
().
length
,
1
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
()[
0
].
label
,
'
foo
'
);
});
});
test
(
'
Only one entry per cell
'
,
function
()
{
withNotebookOutline
([
[
'
## h2
\n
# h1
'
,
'
md
'
,
CellKind
.
Markdown
]
],
outline
=>
{
assert
.
ok
(
outline
instanceof
NotebookCellOutline
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
().
length
,
1
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
()[
0
].
label
,
'
h2
'
);
});
withNotebookOutline
([
[
'
## h2
'
,
'
md
'
,
CellKind
.
Markdown
],
[
'
# h1
'
,
'
md
'
,
CellKind
.
Markdown
]
],
outline
=>
{
assert
.
ok
(
outline
instanceof
NotebookCellOutline
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
().
length
,
2
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
()[
0
].
label
,
'
h2
'
);
assert
.
deepStrictEqual
(
outline
.
config
.
quickPickDataSource
.
getQuickPickElements
()[
1
].
label
,
'
h1
'
);
});
});
});
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
浏览文件 @
b139c10f
...
...
@@ -12,7 +12,7 @@ import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IUndoRedoService
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
{
EditorModel
}
from
'
vs/workbench/common/editor
'
;
import
{
ICellViewModel
,
INotebookEditor
,
INotebookEditorContribution
,
INotebookEditorMouseEvent
,
NotebookLayoutInfo
,
INotebookDeltaDecoration
,
INotebookEditorCreationOptions
,
NotebookEditorOptions
,
ICellOutputViewModel
,
IInsetRenderOutput
,
ICommonCellInfo
,
IGenericCellViewModel
,
INotebookCellOutputLayoutInfo
,
CellEditState
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
ICellViewModel
,
INotebookEditor
,
INotebookEditorContribution
,
INotebookEditorMouseEvent
,
NotebookLayoutInfo
,
INotebookDeltaDecoration
,
INotebookEditorCreationOptions
,
NotebookEditorOptions
,
ICellOutputViewModel
,
IInsetRenderOutput
,
ICommonCellInfo
,
IGenericCellViewModel
,
INotebookCellOutputLayoutInfo
,
CellEditState
,
IActiveNotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
OutputRenderer
}
from
'
vs/workbench/contrib/notebook/browser/view/output/outputRenderer
'
;
import
{
NotebookEventDispatcher
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher
'
;
import
{
CellViewModel
,
IModelDecorationsChangeAccessor
,
NotebookViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
...
...
@@ -59,13 +59,10 @@ export class TestNotebookEditor implements INotebookEditor {
return
this
.
_isDisposed
;
}
get
viewModel
()
{
return
undefined
;
}
creationOptions
:
INotebookEditorCreationOptions
=
{
isEmbedded
:
false
};
constructor
(
)
{
}
constructor
(
readonly
viewModel
:
NotebookViewModel
)
{
}
getSelection
():
ICellRange
|
undefined
{
throw
new
Error
(
'
Method not implemented.
'
);
}
...
...
@@ -137,7 +134,7 @@ export class TestNotebookEditor implements INotebookEditor {
uri
?:
URI
|
undefined
;
textModel
?:
NotebookTextModel
|
undefined
;
hasModel
():
boolean
{
hasModel
():
this
is
IActiveNotebookEditor
{
return
true
;
}
...
...
@@ -457,7 +454,7 @@ export function setupInstantiationService() {
return
instantiationService
;
}
export
function
withTestNotebook
(
accessor
:
ServicesAccessor
,
cells
:
[
string
,
string
,
CellKind
,
IOutputDto
[],
NotebookCellMetadata
][],
callback
:
(
editor
:
TestNotebookEditor
,
viewModel
:
NotebookViewModel
,
textModel
:
NotebookTextModel
)
=>
void
)
{
export
function
withTestNotebook
<
R
=
any
>
(
accessor
:
ServicesAccessor
,
cells
:
[
source
:
string
,
lang
:
string
,
kind
:
CellKind
,
output
?:
IOutputDto
[],
metadata
?:
NotebookCellMetadata
][],
callback
:
(
editor
:
TestNotebookEditor
,
viewModel
:
NotebookViewModel
,
textModel
:
NotebookTextModel
)
=>
R
):
R
{
const
instantiationService
=
accessor
.
get
(
IInstantiationService
);
const
undoRedoService
=
accessor
.
get
(
IUndoRedoService
);
...
...
@@ -465,22 +462,25 @@ export function withTestNotebook(accessor: ServicesAccessor, cells: [string, str
const
bulkEditService
=
accessor
.
get
(
IBulkEditService
);
const
viewType
=
'
notebook
'
;
const
editor
=
new
TestNotebookEditor
();
const
notebook
=
new
NotebookTextModel
(
viewType
,
URI
.
parse
(
'
test
'
),
cells
.
map
(
cell
=>
{
return
{
source
:
cell
[
0
],
language
:
cell
[
1
],
cellKind
:
cell
[
2
],
outputs
:
cell
[
3
],
outputs
:
cell
[
3
]
??
[]
,
metadata
:
cell
[
4
]
};
}),
notebookDocumentMetadataDefaults
,
{
transientMetadata
:
{},
transientOutputs
:
false
},
undoRedoService
,
textModelService
);
const
model
=
new
NotebookEditorTestModel
(
notebook
);
const
eventDispatcher
=
new
NotebookEventDispatcher
();
const
viewModel
=
new
NotebookViewModel
(
viewType
,
model
.
notebook
,
eventDispatcher
,
null
,
instantiationService
,
bulkEditService
,
undoRedoService
);
const
editor
=
new
TestNotebookEditor
(
viewModel
);
callback
(
editor
,
viewModel
,
notebook
);
viewModel
.
dispose
();
return
;
const
res
=
callback
(
editor
,
viewModel
,
notebook
);
if
(
res
instanceof
Promise
)
{
res
.
finally
(()
=>
viewModel
.
dispose
());
}
else
{
viewModel
.
dispose
();
}
return
res
;
}
src/vs/workbench/services/outline/browser/outline.ts
浏览文件 @
b139c10f
...
...
@@ -54,7 +54,7 @@ export interface IQuickPickOutlineElement<E> {
}
export
interface
IQuickPickDataSource
<
E
>
{
getQuickPickElements
():
I
terable
<
IQuickPickOutlineElement
<
E
>>
;
getQuickPickElements
():
I
QuickPickOutlineElement
<
E
>
[]
;
}
export
interface
IOutlineListConfig
<
E
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录