Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
912fff91
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,发现更多精彩内容 >>
提交
912fff91
编写于
5月 17, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change File search result API to only return a string relative path to the search folder
上级
707a20f4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
43 deletion
+50
-43
extensions/search-rg/src/extension.ts
extensions/search-rg/src/extension.ts
+1
-1
extensions/search-rg/src/ripgrepFileSearch.ts
extensions/search-rg/src/ripgrepFileSearch.ts
+2
-2
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-1
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+1
-4
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
...workbench/test/electron-browser/api/extHostSearch.test.ts
+45
-35
未找到文件。
extensions/search-rg/src/extension.ts
浏览文件 @
912fff91
...
...
@@ -22,7 +22,7 @@ class RipgrepSearchProvider implements vscode.SearchProvider {
return
engine
.
provideTextSearchResults
(
query
,
options
,
progress
,
token
);
}
provideFileSearchResults
(
options
:
vscode
.
SearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
SearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
const
engine
=
new
RipgrepFileSearchEngine
(
this
.
outputChannel
);
return
engine
.
provideFileSearchResults
(
options
,
progress
,
token
);
}
...
...
extensions/search-rg/src/ripgrepFileSearch.ts
浏览文件 @
912fff91
...
...
@@ -26,7 +26,7 @@ export class RipgrepFileSearchEngine {
this
.
killRgProcFn
=
()
=>
this
.
rgProc
&&
this
.
rgProc
.
kill
();
}
provideFileSearchResults
(
options
:
vscode
.
SearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
SearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
this
.
outputChannel
.
appendLine
(
`provideFileSearchResults
${
JSON
.
stringify
({
...
options
,
...{
...
...
@@ -85,7 +85,7 @@ export class RipgrepFileSearchEngine {
}
relativeFiles
.
forEach
(
relativeFile
=>
{
progress
.
report
(
vscode
.
Uri
.
file
(
path
.
join
(
cwd
,
relativeFile
))
);
progress
.
report
(
relativeFile
);
});
if
(
last
)
{
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
912fff91
...
...
@@ -85,7 +85,7 @@ declare module 'vscode' {
}
export
interface
SearchProvider
{
provideFileSearchResults
?(
options
:
FileSearchOptions
,
progress
:
Progress
<
Uri
>
,
token
:
CancellationToken
):
Thenable
<
void
>
;
provideFileSearchResults
?(
options
:
FileSearchOptions
,
progress
:
Progress
<
string
>
,
token
:
CancellationToken
):
Thenable
<
void
>
;
provideTextSearchResults
?(
query
:
TextSearchQuery
,
options
:
TextSearchOptions
,
progress
:
Progress
<
TextSearchResult
>
,
token
:
CancellationToken
):
Thenable
<
void
>
;
}
...
...
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
912fff91
...
...
@@ -611,15 +611,12 @@ class FileSearchEngine {
const
queryTester
=
new
QueryGlobTester
(
this
.
config
,
fq
);
const
noSiblingsClauses
=
!
queryTester
.
hasSiblingExcludeClauses
();
const
onProviderResult
=
(
re
sult
:
URI
)
=>
{
const
onProviderResult
=
(
re
lativePath
:
string
)
=>
{
if
(
this
.
isCanceled
)
{
return
;
}
// TODO@roblou - What if it is not relative to the folder query.
// This is slow...
const
relativePath
=
path
.
relative
(
folderStr
,
result
.
fsPath
);
if
(
noSiblingsClauses
)
{
if
(
relativePath
===
this
.
filePattern
)
{
filePatternSeen
=
true
;
...
...
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
浏览文件 @
912fff91
...
...
@@ -8,6 +8,7 @@ import * as assert from 'assert';
import
*
as
path
from
'
path
'
;
import
*
as
extfs
from
'
vs/base/node/extfs
'
;
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IRawFileMatch2
,
IRawSearchQuery
,
QueryType
,
ISearchQuery
,
IPatternInfo
}
from
'
vs/platform/search/common/search
'
;
import
{
MainContext
,
MainThreadSearchShape
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
...
...
@@ -136,6 +137,15 @@ suite('ExtHostSearch', () => {
};
}
function
compareURIsToStrings
(
actual
:
URI
[],
expected
:
string
[])
{
actual
=
actual
.
sort
();
expected
=
expected
.
sort
();
actual
.
forEach
((
a
,
i
)
=>
{
assert
(
strings
.
endsWith
(
a
.
toString
(),
expected
[
i
]));
});
}
function
compareURIs
(
actual
:
URI
[],
expected
:
URI
[])
{
const
sortAndStringify
=
(
arr
:
URI
[])
=>
arr
.
sort
().
map
(
u
=>
u
.
toString
());
...
...
@@ -146,7 +156,7 @@ suite('ExtHostSearch', () => {
test
(
'
no results
'
,
async
()
=>
{
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
return
TPromise
.
wrap
(
null
);
}
});
...
...
@@ -157,13 +167,13 @@ suite('ExtHostSearch', () => {
test
(
'
simple results
'
,
async
()
=>
{
const
reportedResults
=
[
makeAbsoluteURI
(
rootFolderA
,
'
file1.ts
'
)
,
makeAbsoluteURI
(
rootFolderA
,
'
file2.ts
'
)
,
makeAbsoluteURI
(
rootFolderA
,
'
file3.ts
'
)
,
'
file1.ts
'
,
'
file2.ts
'
,
'
file3.ts
'
,
];
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
return
TPromise
.
wrap
(
null
);
}
...
...
@@ -171,7 +181,7 @@ suite('ExtHostSearch', () => {
const
results
=
await
runFileSearch
(
getSimpleQuery
());
assert
.
equal
(
results
.
length
,
3
);
compareURIs
(
results
,
reportedResults
);
compareURIs
ToStrings
(
results
,
reportedResults
);
});
// Sibling clauses
...
...
@@ -184,11 +194,11 @@ suite('ExtHostSearch', () => {
test
(
'
Search canceled
'
,
async
()
=>
{
let
cancelRequested
=
false
;
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
return
new
TPromise
((
resolve
,
reject
)
=>
{
token
.
onCancellationRequested
(()
=>
{
cancelRequested
=
true
;
progress
.
report
(
makeAbsoluteURI
(
rootFolderA
,
'
file1.ts
'
)
);
progress
.
report
(
'
file1.ts
'
);
resolve
(
null
);
// or reject or nothing?
});
...
...
@@ -203,13 +213,13 @@ suite('ExtHostSearch', () => {
test
(
'
provider fail
'
,
async
()
=>
{
const
reportedResults
=
[
makeAbsoluteURI
(
rootFolderA
,
'
file1.ts
'
)
,
makeAbsoluteURI
(
rootFolderA
,
'
file2.ts
'
)
,
makeAbsoluteURI
(
rootFolderA
,
'
file3.ts
'
)
,
'
file1.ts
'
,
'
file2.ts
'
,
'
file3.ts
'
,
];
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
throw
new
Error
(
'
I broke
'
);
}
...
...
@@ -225,7 +235,7 @@ suite('ExtHostSearch', () => {
test
(
'
provider returns null
'
,
async
()
=>
{
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
return
null
;
}
});
...
...
@@ -240,7 +250,7 @@ suite('ExtHostSearch', () => {
test
(
'
all provider calls get global include/excludes
'
,
async
()
=>
{
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
assert
(
options
.
excludes
.
length
===
2
&&
options
.
includes
.
length
===
2
,
'
Missing global include/excludes
'
);
return
TPromise
.
wrap
(
null
);
}
...
...
@@ -269,7 +279,7 @@ suite('ExtHostSearch', () => {
test
(
'
global/local include/excludes combined
'
,
async
()
=>
{
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
if
(
options
.
folder
.
toString
()
===
rootFolderA
.
toString
())
{
assert
.
deepEqual
(
options
.
includes
.
sort
(),
[
'
*.ts
'
,
'
foo
'
]);
assert
.
deepEqual
(
options
.
excludes
.
sort
(),
[
'
*.js
'
,
'
bar
'
]);
...
...
@@ -311,7 +321,7 @@ suite('ExtHostSearch', () => {
test
(
'
include/excludes resolved correctly
'
,
async
()
=>
{
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
assert
.
deepEqual
(
options
.
includes
.
sort
(),
[
'
*.jsx
'
,
'
*.ts
'
]);
assert
.
deepEqual
(
options
.
excludes
.
sort
(),
[]);
...
...
@@ -349,12 +359,12 @@ suite('ExtHostSearch', () => {
test
(
'
basic sibling exclude clause
'
,
async
()
=>
{
const
reportedResults
=
[
makeAbsoluteURI
(
rootFolderA
,
'
file1.ts
'
)
,
makeAbsoluteURI
(
rootFolderA
,
'
file1.js
'
)
,
'
file1.ts
'
,
'
file1.js
'
,
];
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
return
TPromise
.
wrap
(
null
);
}
...
...
@@ -385,19 +395,19 @@ suite('ExtHostSearch', () => {
test
(
'
multiroot sibling exclude clause
'
,
async
()
=>
{
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
let
reportedResults
;
if
(
options
.
folder
.
fsPath
===
rootFolderA
.
fsPath
)
{
reportedResults
=
[
makeAbsoluteURI
(
rootFolderA
,
'
folder/fileA.scss
'
)
,
makeAbsoluteURI
(
rootFolderA
,
'
folder/fileA.css
'
)
,
makeAbsoluteURI
(
rootFolderA
,
'
folder/file2.css
'
)
'
folder/fileA.scss
'
,
'
folder/fileA.css
'
,
'
folder/file2.css
'
];
}
else
{
reportedResults
=
[
makeAbsoluteURI
(
rootFolderB
,
'
fileB.ts
'
)
,
makeAbsoluteURI
(
rootFolderB
,
'
fileB.js
'
)
,
makeAbsoluteURI
(
rootFolderB
,
'
file3.js
'
)
'
fileB.ts
'
,
'
fileB.js
'
,
'
file3.js
'
];
}
...
...
@@ -456,8 +466,8 @@ suite('ExtHostSearch', () => {
let
wasCanceled
=
false
;
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
path
.
basename
(
r
.
fsPath
)
));
token
.
onCancellationRequested
(()
=>
wasCanceled
=
true
);
return
TPromise
.
wrap
(
null
);
...
...
@@ -492,8 +502,8 @@ suite('ExtHostSearch', () => {
let
wasCanceled
=
false
;
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
path
.
basename
(
r
.
fsPath
)
));
token
.
onCancellationRequested
(()
=>
wasCanceled
=
true
);
return
TPromise
.
wrap
(
null
);
...
...
@@ -522,7 +532,7 @@ suite('ExtHostSearch', () => {
test
(
'
multiroot max results
'
,
async
()
=>
{
let
cancels
=
0
;
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
token
.
onCancellationRequested
(()
=>
cancels
++
);
// Provice results async so it has a chance to invoke every provider
...
...
@@ -533,7 +543,7 @@ suite('ExtHostSearch', () => {
'
file2.ts
'
,
'
file3.ts
'
,
].
forEach
(
f
=>
{
progress
.
report
(
makeAbsoluteURI
(
options
.
folder
,
f
)
);
progress
.
report
(
f
);
});
});
}
...
...
@@ -568,8 +578,8 @@ suite('ExtHostSearch', () => {
];
await
registerTestSearchProvider
({
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
vscode
.
Uri
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
r
));
provideFileSearchResults
(
options
:
vscode
.
FileSearchOptions
,
progress
:
vscode
.
Progress
<
string
>
,
token
:
vscode
.
CancellationToken
):
Thenable
<
void
>
{
reportedResults
.
forEach
(
r
=>
progress
.
report
(
path
.
basename
(
r
.
fsPath
)
));
return
TPromise
.
wrap
(
null
);
}
});
...
...
@@ -601,7 +611,7 @@ suite('ExtHostSearch', () => {
// ];
// await registerTestSearchProvider({
// provideFileSearchResults(options: vscode.FileSearchOptions, progress: vscode.Progress<
vscode.Uri
>, token: vscode.CancellationToken): Thenable<void> {
// provideFileSearchResults(options: vscode.FileSearchOptions, progress: vscode.Progress<
string
>, token: vscode.CancellationToken): Thenable<void> {
// reportedResults.forEach(r => progress.report(r));
// return TPromise.wrap(null);
// }
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录