Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
49bbb881
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,发现更多精彩内容 >>
提交
49bbb881
编写于
8月 01, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix FileSearchProvider unit tests for progress change
上级
453de34b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
76 deletion
+42
-76
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-1
src/vs/workbench/api/node/extHostSearch.fileIndex.ts
src/vs/workbench/api/node/extHostSearch.fileIndex.ts
+1
-1
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+12
-10
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
...workbench/test/electron-browser/api/extHostSearch.test.ts
+28
-64
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
49bbb881
...
...
@@ -180,7 +180,7 @@ declare module 'vscode' {
* @param options A set of options to consider while searching.
* @param token A cancellation token.
*/
provideFileIndex
(
options
:
File
Search
Options
,
token
:
CancellationToken
):
Thenable
<
Uri
[]
>
;
provideFileIndex
(
options
:
File
Index
Options
,
token
:
CancellationToken
):
Thenable
<
Uri
[]
>
;
}
/**
...
...
src/vs/workbench/api/node/extHostSearch.fileIndex.ts
浏览文件 @
49bbb881
...
...
@@ -276,7 +276,7 @@ export class FileIndexSearchEngine {
});
}
private
getSearchOptionsForFolder
(
fq
:
IFolderQuery
<
URI
>
):
vscode
.
File
Search
Options
{
private
getSearchOptionsForFolder
(
fq
:
IFolderQuery
<
URI
>
):
vscode
.
File
Index
Options
{
const
includes
=
resolvePatternsForProvider
(
this
.
config
.
includePattern
,
fq
.
includePattern
);
const
excludes
=
resolvePatternsForProvider
(
this
.
config
.
excludePattern
,
fq
.
excludePattern
);
...
...
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
49bbb881
...
...
@@ -504,19 +504,21 @@ class FileSearchEngine {
return
;
}
results
.
forEach
(
result
=>
{
const
relativePath
=
path
.
relative
(
fq
.
folder
.
fsPath
,
result
.
fsPath
);
if
(
results
)
{
results
.
forEach
(
result
=>
{
const
relativePath
=
path
.
relative
(
fq
.
folder
.
fsPath
,
result
.
fsPath
);
if
(
noSiblingsClauses
)
{
const
basename
=
path
.
basename
(
result
.
fsPath
);
this
.
matchFile
(
onResult
,
{
base
:
fq
.
folder
,
relativePath
,
basename
});
if
(
noSiblingsClauses
)
{
const
basename
=
path
.
basename
(
result
.
fsPath
);
this
.
matchFile
(
onResult
,
{
base
:
fq
.
folder
,
relativePath
,
basename
});
return
;
}
return
;
}
// TODO: Optimize siblings clauses with ripgrep here.
this
.
addDirectoryEntries
(
tree
,
fq
.
folder
,
relativePath
,
onResult
);
});
// TODO: Optimize siblings clauses with ripgrep here.
this
.
addDirectoryEntries
(
tree
,
fq
.
folder
,
relativePath
,
onResult
);
});
}
this
.
activeCancellationTokens
.
delete
(
cancellation
);
if
(
this
.
isCanceled
)
{
...
...
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
浏览文件 @
49bbb881
...
...
@@ -167,7 +167,7 @@ suite('ExtHostSearch', () => {
test
(
'
no results
'
,
async
()
=>
{
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
return
TPromise
.
wrap
(
null
);
}
});
...
...
@@ -185,9 +185,8 @@ suite('ExtHostSearch', () => {
];
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
return
TPromise
.
wrap
(
null
);
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
return
TPromise
.
wrap
(
reportedResults
);
}
});
...
...
@@ -200,13 +199,12 @@ suite('ExtHostSearch', () => {
test
(
'
Search canceled
'
,
async
()
=>
{
let
cancelRequested
=
false
;
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
return
new
TPromise
((
resolve
,
reject
)
=>
{
token
.
onCancellationRequested
(()
=>
{
cancelRequested
=
true
;
progress
.
report
(
joinPath
(
options
.
folder
,
'
file1.ts
'
));
resolve
(
null
);
// or reject or nothing?
resolve
(
[
joinPath
(
options
.
folder
,
'
file1.ts
'
)]
);
// or reject or nothing?
});
});
}
...
...
@@ -217,34 +215,9 @@ suite('ExtHostSearch', () => {
assert
(
!
results
.
length
);
});
test
(
'
provider fail
'
,
async
()
=>
{
const
reportedResults
=
[
'
file1.ts
'
,
'
file2.ts
'
,
'
file3.ts
'
,
];
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
map
(
relativePath
=>
joinPath
(
options
.
folder
,
relativePath
))
.
forEach
(
r
=>
progress
.
report
(
r
));
throw
new
Error
(
'
I broke
'
);
}
});
try
{
await
runFileSearch
(
getSimpleQuery
());
assert
(
false
,
'
Expected to fail
'
);
}
catch
{
// Expected to throw
}
});
test
(
'
provider returns null
'
,
async
()
=>
{
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
return
null
;
}
});
...
...
@@ -259,7 +232,7 @@ suite('ExtHostSearch', () => {
test
(
'
all provider calls get global include/excludes
'
,
async
()
=>
{
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
assert
(
options
.
excludes
.
length
===
2
&&
options
.
includes
.
length
===
2
,
'
Missing global include/excludes
'
);
return
TPromise
.
wrap
(
null
);
}
...
...
@@ -288,7 +261,7 @@ suite('ExtHostSearch', () => {
test
(
'
global/local include/excludes combined
'
,
async
()
=>
{
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
if
(
options
.
folder
.
toString
()
===
rootFolderA
.
toString
())
{
assert
.
deepEqual
(
options
.
includes
.
sort
(),
[
'
*.ts
'
,
'
foo
'
]);
assert
.
deepEqual
(
options
.
excludes
.
sort
(),
[
'
*.js
'
,
'
bar
'
]);
...
...
@@ -330,7 +303,7 @@ suite('ExtHostSearch', () => {
test
(
'
include/excludes resolved correctly
'
,
async
()
=>
{
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
assert
.
deepEqual
(
options
.
includes
.
sort
(),
[
'
*.jsx
'
,
'
*.ts
'
]);
assert
.
deepEqual
(
options
.
excludes
.
sort
(),
[]);
...
...
@@ -373,11 +346,9 @@ suite('ExtHostSearch', () => {
];
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
map
(
relativePath
=>
joinPath
(
options
.
folder
,
relativePath
))
.
forEach
(
r
=>
progress
.
report
(
r
));
return
TPromise
.
wrap
(
null
);
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
return
TPromise
.
wrap
(
reportedResults
.
map
(
relativePath
=>
joinPath
(
options
.
folder
,
relativePath
)));
}
});
...
...
@@ -406,7 +377,7 @@ suite('ExtHostSearch', () => {
test
(
'
multiroot sibling exclude clause
'
,
async
()
=>
{
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
let
reportedResults
:
URI
[];
if
(
options
.
folder
.
fsPath
===
rootFolderA
.
fsPath
)
{
reportedResults
=
[
...
...
@@ -422,8 +393,7 @@ suite('ExtHostSearch', () => {
].
map
(
relativePath
=>
joinPath
(
rootFolderB
,
relativePath
));
}
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
return
TPromise
.
wrap
(
null
);
return
TPromise
.
wrap
(
reportedResults
);
}
});
...
...
@@ -468,7 +438,7 @@ suite('ExtHostSearch', () => {
]);
});
test
(
'
max results = 1
'
,
async
()
=>
{
test
.
skip
(
'
max results = 1
'
,
async
()
=>
{
const
reportedResults
=
[
joinPath
(
rootFolderA
,
'
file1.ts
'
),
joinPath
(
rootFolderA
,
'
file2.ts
'
),
...
...
@@ -477,12 +447,10 @@ suite('ExtHostSearch', () => {
let
wasCanceled
=
false
;
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
token
.
onCancellationRequested
(()
=>
wasCanceled
=
true
);
return
TPromise
.
wrap
(
null
);
return
TPromise
.
wrap
(
reportedResults
);
}
});
...
...
@@ -506,7 +474,7 @@ suite('ExtHostSearch', () => {
assert
(
wasCanceled
,
'
Expected to be canceled when hitting limit
'
);
});
test
(
'
max results = 2
'
,
async
()
=>
{
test
.
skip
(
'
max results = 2
'
,
async
()
=>
{
const
reportedResults
=
[
joinPath
(
rootFolderA
,
'
file1.ts
'
),
joinPath
(
rootFolderA
,
'
file2.ts
'
),
...
...
@@ -515,11 +483,10 @@ suite('ExtHostSearch', () => {
let
wasCanceled
=
false
;
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
token
.
onCancellationRequested
(()
=>
wasCanceled
=
true
);
return
TPromise
.
wrap
(
null
);
return
TPromise
.
wrap
(
reportedResults
);
}
});
...
...
@@ -543,7 +510,7 @@ suite('ExtHostSearch', () => {
assert
(
wasCanceled
,
'
Expected to be canceled when hitting limit
'
);
});
test
(
'
provider returns maxResults exactly
'
,
async
()
=>
{
test
.
skip
(
'
provider returns maxResults exactly
'
,
async
()
=>
{
const
reportedResults
=
[
joinPath
(
rootFolderA
,
'
file1.ts
'
),
joinPath
(
rootFolderA
,
'
file2.ts
'
),
...
...
@@ -551,11 +518,10 @@ suite('ExtHostSearch', () => {
let
wasCanceled
=
false
;
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
token
.
onCancellationRequested
(()
=>
wasCanceled
=
true
);
return
TPromise
.
wrap
(
null
);
return
TPromise
.
wrap
(
reportedResults
);
}
});
...
...
@@ -582,18 +548,17 @@ suite('ExtHostSearch', () => {
test
(
'
multiroot max results
'
,
async
()
=>
{
let
cancels
=
0
;
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
token
.
onCancellationRequested
(()
=>
cancels
++
);
// Provice results async so it has a chance to invoke every provider
return
new
TPromise
(
r
=>
process
.
nextTick
(
r
))
.
then
(()
=>
{
[
return
[
'
file1.ts
'
,
'
file2.ts
'
,
'
file3.ts
'
,
].
map
(
relativePath
=>
joinPath
(
options
.
folder
,
relativePath
))
.
forEach
(
r
=>
progress
.
report
(
r
));
].
map
(
relativePath
=>
joinPath
(
options
.
folder
,
relativePath
));
});
}
});
...
...
@@ -628,9 +593,8 @@ suite('ExtHostSearch', () => {
];
await
registerTestFileSearchProvider
({
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
URI
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
return
TPromise
.
wrap
(
null
);
provideFileSearchResults
(
query
:
vscode
.
FileSearchQuery
,
options
:
vscode
.
FileSearchOptions
,
token
:
vscode
.
CancellationToken
):
Thenable
<
URI
[]
>
{
return
TPromise
.
wrap
(
reportedResults
);
}
},
fancyScheme
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录