Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bc5a6ea9
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,发现更多精彩内容 >>
提交
bc5a6ea9
编写于
3月 15, 2017
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Return single items
上级
2b943503
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
16 addition
and
21 deletion
+16
-21
src/vs/workbench/services/search/node/rawSearchService.ts
src/vs/workbench/services/search/node/rawSearchService.ts
+8
-9
src/vs/workbench/services/search/node/ripgrepTextSearch.ts
src/vs/workbench/services/search/node/ripgrepTextSearch.ts
+8
-12
未找到文件。
src/vs/workbench/services/search/node/rawSearchService.ts
浏览文件 @
bc5a6ea9
...
...
@@ -264,9 +264,8 @@ export class SearchService implements IRawSearchService {
return
new
PPromise
<
ISerializedSearchComplete
,
IRawProgressItem
<
ISerializedFileMatch
>>
((
c
,
e
,
p
)
=>
{
// Use BatchedCollector to get new results to the frontend every 2s at least, until 50 results have been returned
const
collector
=
new
BatchedCollector
<
ISerializedFileMatch
>
(
batchSize
,
p
);
engine
.
search
((
matches
)
=>
{
const
totalMatches
=
matches
.
reduce
((
acc
,
m
)
=>
acc
+
m
.
numMatches
,
0
);
collector
.
addItems
(
matches
,
totalMatches
);
engine
.
search
((
match
)
=>
{
collector
.
addItem
(
match
,
match
.
numMatches
);
},
(
progress
)
=>
{
p
(
progress
);
},
(
error
,
stats
)
=>
{
...
...
@@ -380,20 +379,20 @@ class BatchedCollector<T> {
constructor
(
private
maxBatchSize
:
number
,
private
cb
:
(
items
:
T
|
T
[])
=>
void
)
{
}
addItem
s
(
items
:
T
[]
,
size
:
number
):
void
{
if
(
!
item
s
)
{
addItem
(
item
:
T
,
size
:
number
):
void
{
if
(
!
item
)
{
return
;
}
if
(
this
.
maxBatchSize
>
0
)
{
this
.
addItem
sToBatch
(
items
,
size
);
this
.
addItem
ToBatch
(
item
,
size
);
}
else
{
this
.
cb
(
item
s
);
this
.
cb
(
item
);
}
}
private
addItem
sToBatch
(
items
:
T
[]
,
size
:
number
):
void
{
this
.
batch
=
this
.
batch
.
concat
(
items
);
private
addItem
ToBatch
(
item
:
T
,
size
:
number
):
void
{
this
.
batch
.
push
(
item
);
this
.
batchSize
+=
size
;
if
(
this
.
totalNumberCompleted
<
BatchedCollector
.
START_BATCH_AFTER_COUNT
)
{
// Flush because we aren't batching yet
...
...
src/vs/workbench/services/search/node/ripgrepTextSearch.ts
浏览文件 @
bc5a6ea9
...
...
@@ -14,7 +14,7 @@ import { ILineMatch, IProgress } from 'vs/platform/search/common/search';
import
{
ISerializedFileMatch
,
ISerializedSearchComplete
,
IRawSearch
,
ISearchEngine
}
from
'
./search
'
;
export
class
RipgrepEngine
implements
ISearchEngine
<
ISerializedFileMatch
[]
>
{
export
class
RipgrepEngine
implements
ISearchEngine
<
ISerializedFileMatch
>
{
private
static
RESULT_REGEX
=
/^
\u
001b
\[
m
(\d
+
)\u
001b
\[
m:
(
.*
)
$/
;
private
static
FILE_REGEX
=
/^
\u
001b
\[
m
(
.+
)\u
001b
\[
m$/
;
...
...
@@ -38,17 +38,14 @@ export class RipgrepEngine implements ISearchEngine<ISerializedFileMatch[]> {
this
.
rgProc
.
kill
();
}
search
(
onResult
:
(
match
:
ISerializedFileMatch
[])
=>
void
,
onProgress
:
(
progress
:
IProgress
)
=>
void
,
done
:
(
error
:
Error
,
complete
:
ISerializedSearchComplete
)
=>
void
):
void
{
this
.
searchNextFolder
(
onResult
,
onProgress
,
done
);
}
private
searchNextFolder
(
onResult
:
(
match
:
ISerializedFileMatch
[])
=>
void
,
onProgress
:
(
progress
:
IProgress
)
=>
void
,
done
:
(
error
:
Error
,
complete
:
ISerializedSearchComplete
)
=>
void
):
void
{
search
(
onResult
:
(
match
:
ISerializedFileMatch
)
=>
void
,
onProgress
:
(
progress
:
IProgress
)
=>
void
,
done
:
(
error
:
Error
,
complete
:
ISerializedSearchComplete
)
=>
void
):
void
{
if
(
this
.
config
.
rootFolders
.
length
)
{
this
.
searchFolder
(
this
.
config
.
rootFolders
.
shift
(),
onResult
,
onProgress
,
done
);
// Only a single root folder supported by VS Code right now
this
.
searchFolder
(
this
.
config
.
rootFolders
[
0
],
onResult
,
onProgress
,
done
);
}
}
private
searchFolder
(
rootFolder
:
string
,
onResult
:
(
match
:
ISerializedFileMatch
[]
)
=>
void
,
onProgress
:
(
progress
:
IProgress
)
=>
void
,
done
:
(
error
:
Error
,
complete
:
ISerializedSearchComplete
)
=>
void
):
void
{
private
searchFolder
(
rootFolder
:
string
,
onResult
:
(
match
:
ISerializedFileMatch
)
=>
void
,
onProgress
:
(
progress
:
IProgress
)
=>
void
,
done
:
(
error
:
Error
,
complete
:
ISerializedSearchComplete
)
=>
void
):
void
{
const
rgArgs
=
this
.
getRgArgs
();
console
.
log
(
`rg
${
rgArgs
.
join
(
'
'
)}
, cwd:
${
rootFolder
}
`
);
this
.
rgProc
=
cp
.
spawn
(
rgPath
,
rgArgs
,
{
cwd
:
rootFolder
});
...
...
@@ -109,7 +106,7 @@ export class RipgrepEngine implements ISearchEngine<ISerializedFileMatch[]> {
if
(
this
.
numResults
>=
this
.
config
.
maxResults
)
{
this
.
cancel
();
onResult
(
[
fileMatch
.
serialize
()]
);
onResult
(
fileMatch
.
serialize
()
);
done
(
null
,
{
limitHit
:
true
,
stats
:
null
...
...
@@ -133,7 +130,7 @@ export class RipgrepEngine implements ISearchEngine<ISerializedFileMatch[]> {
// Line is a file path - send all collected results for the previous file path
if
(
fileMatch
)
{
// Check fileMatch against other exclude globs, and fix numResults
onResult
(
[
fileMatch
.
serialize
()]
);
onResult
(
fileMatch
.
serialize
()
);
}
fileMatch
=
new
FileMatch
(
path
.
join
(
rootFolder
,
r
[
1
]));
...
...
@@ -153,8 +150,7 @@ export class RipgrepEngine implements ISearchEngine<ISerializedFileMatch[]> {
this
.
rgProc
=
null
;
console
.
log
(
`closed with
${
code
}
`
);
if
(
fileMatch
)
{
console
.
log
(
`calling onResult`
);
onResult
([
fileMatch
.
serialize
()]);
onResult
(
fileMatch
.
serialize
());
}
if
(
!
this
.
isDone
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录