Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
77611570
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,发现更多精彩内容 >>
提交
77611570
编写于
4月 13, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update results on file create
上级
79098619
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
41 addition
and
1 deletion
+41
-1
extensions/markdown-language-features/src/features/workspaceSymbolProvider.ts
...language-features/src/features/workspaceSymbolProvider.ts
+15
-0
extensions/markdown-language-features/src/test/workspaceSymbolProvider.test.ts
...anguage-features/src/test/workspaceSymbolProvider.test.ts
+26
-1
未找到文件。
extensions/markdown-language-features/src/features/workspaceSymbolProvider.ts
浏览文件 @
77611570
...
...
@@ -12,12 +12,14 @@ export interface WorkspaceMarkdownDocumentProvider {
getAllMarkdownDocuments
():
Thenable
<
vscode
.
TextDocument
[]
>
;
readonly
onDidChangeMarkdownDocument
:
vscode
.
Event
<
vscode
.
TextDocument
>
;
readonly
onDidCreateMarkdownDocument
:
vscode
.
Event
<
vscode
.
TextDocument
>
;
readonly
onDidDeleteMarkdownDocument
:
vscode
.
Event
<
vscode
.
Uri
>
;
}
class
VSCodeWorkspaceMarkdownDocumentProvider
implements
WorkspaceMarkdownDocumentProvider
{
private
readonly
_onDidChangeMarkdownDocumentEmitter
=
new
vscode
.
EventEmitter
<
vscode
.
TextDocument
>
();
private
readonly
_onDidCreateMarkdownDocumentEmitter
=
new
vscode
.
EventEmitter
<
vscode
.
TextDocument
>
();
private
readonly
_onDidDeleteMarkdownDocumentEmitter
=
new
vscode
.
EventEmitter
<
vscode
.
Uri
>
();
private
_watcher
:
vscode
.
FileSystemWatcher
|
undefined
;
...
...
@@ -46,6 +48,11 @@ class VSCodeWorkspaceMarkdownDocumentProvider implements WorkspaceMarkdownDocume
return
this
.
_onDidChangeMarkdownDocumentEmitter
.
event
;
}
public
get
onDidCreateMarkdownDocument
()
{
this
.
ensureWatcher
();
return
this
.
_onDidCreateMarkdownDocumentEmitter
.
event
;
}
public
get
onDidDeleteMarkdownDocument
()
{
this
.
ensureWatcher
();
return
this
.
_onDidDeleteMarkdownDocumentEmitter
.
event
;
...
...
@@ -65,6 +72,13 @@ class VSCodeWorkspaceMarkdownDocumentProvider implements WorkspaceMarkdownDocume
}
},
this
,
this
.
_disposables
);
this
.
_watcher
.
onDidCreate
(
async
resource
=>
{
const
document
=
await
vscode
.
workspace
.
openTextDocument
(
resource
);
if
(
isMarkdownFile
(
document
))
{
this
.
_onDidCreateMarkdownDocumentEmitter
.
fire
(
document
);
}
},
this
,
this
.
_disposables
);
this
.
_watcher
.
onDidDelete
(
async
resource
=>
{
this
.
_onDidDeleteMarkdownDocumentEmitter
.
fire
(
resource
);
},
this
,
this
.
_disposables
);
...
...
@@ -88,6 +102,7 @@ export default class MarkdownWorkspaceSymbolProvider implements vscode.Workspace
this
.
_symbolCachePopulated
=
true
;
this
.
_workspaceMarkdownDocumentProvider
.
onDidChangeMarkdownDocument
(
this
.
onDidChangeDocument
,
this
,
this
.
_disposables
);
this
.
_workspaceMarkdownDocumentProvider
.
onDidCreateMarkdownDocument
(
this
.
onDidChangeDocument
,
this
,
this
.
_disposables
);
this
.
_workspaceMarkdownDocumentProvider
.
onDidDeleteMarkdownDocument
(
this
.
onDidDeleteDocument
,
this
,
this
.
_disposables
);
}
...
...
extensions/markdown-language-features/src/test/workspaceSymbolProvider.test.ts
浏览文件 @
77611570
...
...
@@ -75,7 +75,6 @@ suite('markdown.WorkspaceSymbolProvider', () => {
]);
const
provider
=
new
MarkdownWorkspaceSymbolProvider
(
symbolProvider
,
workspaceFileProvider
);
assert
.
strictEqual
((
await
provider
.
provideWorkspaceSymbols
(
''
)).
length
,
1
);
// delete file
...
...
@@ -83,6 +82,22 @@ suite('markdown.WorkspaceSymbolProvider', () => {
const
newSymbols
=
await
provider
.
provideWorkspaceSymbols
(
''
);
assert
.
strictEqual
(
newSymbols
.
length
,
0
);
});
test
(
'
Should update results when markdown file is created
'
,
async
()
=>
{
const
testFileName
=
vscode
.
Uri
.
parse
(
'
test.md
'
);
const
workspaceFileProvider
=
new
InMemoryWorkspaceMarkdownDocumentProvider
([
new
InMemoryDocument
(
testFileName
,
`# header1`
)
]);
const
provider
=
new
MarkdownWorkspaceSymbolProvider
(
symbolProvider
,
workspaceFileProvider
);
assert
.
strictEqual
((
await
provider
.
provideWorkspaceSymbols
(
''
)).
length
,
1
);
// Creat file
workspaceFileProvider
.
createDocument
(
new
InMemoryDocument
(
vscode
.
Uri
.
parse
(
'
test2.md
'
),
`# new header\nabc\n## header2`
));
const
newSymbols
=
await
provider
.
provideWorkspaceSymbols
(
''
);
assert
.
strictEqual
(
newSymbols
.
length
,
3
);
});
});
...
...
@@ -102,6 +117,9 @@ class InMemoryWorkspaceMarkdownDocumentProvider implements WorkspaceMarkdownDocu
private
readonly
_onDidChangeMarkdownDocumentEmitter
=
new
vscode
.
EventEmitter
<
vscode
.
TextDocument
>
();
public
onDidChangeMarkdownDocument
=
this
.
_onDidChangeMarkdownDocumentEmitter
.
event
;
private
readonly
_onDidCreateMarkdownDocumentEmitter
=
new
vscode
.
EventEmitter
<
vscode
.
TextDocument
>
();
public
onDidCreateMarkdownDocument
=
this
.
_onDidCreateMarkdownDocumentEmitter
.
event
;
private
readonly
_onDidDeleteMarkdownDocumentEmitter
=
new
vscode
.
EventEmitter
<
vscode
.
Uri
>
();
public
onDidDeleteMarkdownDocument
=
this
.
_onDidDeleteMarkdownDocumentEmitter
.
event
;
...
...
@@ -110,6 +128,13 @@ class InMemoryWorkspaceMarkdownDocumentProvider implements WorkspaceMarkdownDocu
this
.
_onDidChangeMarkdownDocumentEmitter
.
fire
(
document
);
}
public
createDocument
(
document
:
vscode
.
TextDocument
)
{
assert
.
ok
(
!
this
.
_documents
.
has
(
document
.
uri
.
fsPath
));
this
.
_documents
.
set
(
document
.
uri
.
fsPath
,
document
);
this
.
_onDidCreateMarkdownDocumentEmitter
.
fire
(
document
);
}
public
deleteDocument
(
resource
:
vscode
.
Uri
)
{
this
.
_documents
.
delete
(
resource
.
fsPath
);
this
.
_onDidDeleteMarkdownDocumentEmitter
.
fire
(
resource
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录