Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7b61ee4f
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,发现更多精彩内容 >>
提交
7b61ee4f
编写于
10月 19, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Text search - add telemetry for searches with invalid encoding
上级
c70a347e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
70 addition
and
59 deletion
+70
-59
src/vs/platform/search/common/search.ts
src/vs/platform/search/common/search.ts
+0
-1
src/vs/workbench/parts/search/common/queryBuilder.ts
src/vs/workbench/parts/search/common/queryBuilder.ts
+0
-1
src/vs/workbench/services/search/node/rawSearchService.ts
src/vs/workbench/services/search/node/rawSearchService.ts
+1
-9
src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts
...workbench/services/search/node/ripgrepTextSearchEngine.ts
+3
-13
src/vs/workbench/services/search/node/searchService.ts
src/vs/workbench/services/search/node/searchService.ts
+39
-2
src/vs/workbench/services/search/node/textSearchAdapter.ts
src/vs/workbench/services/search/node/textSearchAdapter.ts
+13
-11
src/vs/workbench/services/search/node/textSearchManager.ts
src/vs/workbench/services/search/node/textSearchManager.ts
+1
-1
src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts
...h/services/search/test/node/textSearch.integrationTest.ts
+13
-21
未找到文件。
src/vs/platform/search/common/search.ts
浏览文件 @
7b61ee4f
...
...
@@ -107,7 +107,6 @@ export interface ITextQueryProps<U extends UriComponents> extends ICommonQueryPr
contentPattern
?:
IPatternInfo
;
previewOptions
?:
ITextSearchPreviewOptions
;
fileEncoding
?:
string
;
maxFileSize
?:
number
;
usePCRE2
?:
boolean
;
}
...
...
src/vs/workbench/parts/search/common/queryBuilder.ts
浏览文件 @
7b61ee4f
...
...
@@ -76,7 +76,6 @@ export class QueryBuilder {
type
:
QueryType
.
Text
,
contentPattern
,
previewOptions
:
options
&&
options
.
previewOptions
,
fileEncoding
:
options
&&
options
.
fileEncoding
,
maxFileSize
:
options
&&
options
.
maxFileSize
,
usePCRE2
:
searchConfig
.
search
.
usePCRE2
};
...
...
src/vs/workbench/services/search/node/rawSearchService.ts
浏览文件 @
7b61ee4f
...
...
@@ -87,15 +87,7 @@ export class SearchService implements IRawSearchService {
config
.
maxFileSize
=
MAX_FILE_SIZE
;
const
engine
=
new
TextSearchEngineAdapter
(
config
);
return
new
Promise
<
ISerializedSearchSuccess
>
((
c
,
e
)
=>
{
engine
.
search
(
token
,
progressCallback
,
progressCallback
,
(
error
,
stats
)
=>
{
if
(
error
)
{
e
(
error
);
}
else
{
c
(
stats
);
}
});
});
return
engine
.
search
(
token
,
progressCallback
,
progressCallback
);
}
doFileSearch
(
EngineClass
:
{
new
(
config
:
IRawSearch
):
ISearchEngine
<
IRawFileMatch
>
;
},
config
:
IRawSearch
,
progressCallback
:
IProgressCallback
,
token
?:
CancellationToken
,
batchSize
?:
number
):
TPromise
<
ISerializedSearchSuccess
>
{
...
...
src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts
浏览文件 @
7b61ee4f
...
...
@@ -118,8 +118,8 @@ export class RipgrepTextSearchEngine {
export
function
rgErrorMsgForDisplay
(
msg
:
string
):
Maybe
<
string
>
{
const
firstLine
=
msg
.
split
(
'
\n
'
)[
0
].
trim
();
if
(
startsWith
(
firstLine
,
'
Error parsing regex
'
))
{
return
firstLine
;
if
(
startsWith
(
firstLine
,
'
regex parse error
'
))
{
return
'
Regex parse error
'
;
}
let
match
=
firstLine
.
match
(
/grep config error: unknown encoding:
(
.*
)
/
);
...
...
@@ -127,21 +127,11 @@ export function rgErrorMsgForDisplay(msg: string): Maybe<string> {
return
`Unknown encoding:
${
match
[
1
]}
`
;
}
if
(
startsWith
(
firstLine
,
'
error parsing glob
'
))
{
if
(
startsWith
(
firstLine
,
'
error parsing glob
'
)
||
startsWith
(
firstLine
,
'
the literal
'
)
)
{
// Uppercase first letter
return
firstLine
.
charAt
(
0
).
toUpperCase
()
+
firstLine
.
substr
(
1
);
}
if
(
firstLine
===
`Literal '\\n' not allowed.`
)
{
// I won't localize this because none of the Ripgrep error messages are localized
return
`Literal '\\n' currently not supported`
;
}
if
(
startsWith
(
firstLine
,
'
Literal
'
))
{
// Other unsupported chars
return
firstLine
;
}
return
undefined
;
}
...
...
src/vs/workbench/services/search/node/searchService.ts
浏览文件 @
7b61ee4f
...
...
@@ -236,6 +236,17 @@ export class SearchService extends Disposable implements ISearchService {
this
.
sendTelemetry
(
query
,
endToEndTime
,
complete
);
});
return
completes
;
},
errs
=>
{
const
endToEndTime
=
e2eSW
.
elapsed
();
this
.
logService
.
trace
(
`SearchService#search:
${
endToEndTime
}
ms`
);
errs
=
errs
.
filter
(
e
=>
!!
e
);
errs
.
forEach
(
e
=>
{
this
.
sendTelemetry
(
query
,
endToEndTime
,
null
,
e
);
});
throw
errs
[
0
];
});
}
...
...
@@ -252,14 +263,14 @@ export class SearchService extends Disposable implements ISearchService {
return
queries
;
}
private
sendTelemetry
(
query
:
ISearchQuery
,
endToEndTime
:
number
,
complete
:
ISearchComplete
):
void
{
private
sendTelemetry
(
query
:
ISearchQuery
,
endToEndTime
:
number
,
complete
?:
ISearchComplete
,
err
?:
Error
):
void
{
const
fileSchemeOnly
=
query
.
folderQueries
.
every
(
fq
=>
fq
.
folder
.
scheme
===
'
file
'
);
const
otherSchemeOnly
=
query
.
folderQueries
.
every
(
fq
=>
fq
.
folder
.
scheme
!==
'
file
'
);
const
scheme
=
fileSchemeOnly
?
'
file
'
:
otherSchemeOnly
?
'
other
'
:
'
mixed
'
;
if
(
query
.
type
===
QueryType
.
File
&&
complete
.
stats
)
{
if
(
query
.
type
===
QueryType
.
File
&&
complete
&&
complete
.
stats
)
{
const
fileSearchStats
=
complete
.
stats
as
IFileSearchStats
;
if
(
fileSearchStats
.
fromCache
)
{
const
cacheStats
:
ICachedSearchStats
=
fileSearchStats
.
detailStats
as
ICachedSearchStats
;
...
...
@@ -328,6 +339,32 @@ export class SearchService extends Disposable implements ISearchService {
scheme
});
}
}
else
if
(
query
.
type
===
QueryType
.
Text
)
{
let
errorType
:
string
;
if
(
err
)
{
errorType
=
err
.
message
.
indexOf
(
'
Regex parse error
'
)
>=
0
?
'
regex
'
:
err
.
message
.
indexOf
(
'
Unknown encoding
'
)
>=
0
?
'
encoding
'
:
err
.
message
.
indexOf
(
'
Error parsing glob
'
)
>=
0
?
'
glob
'
:
err
.
message
.
indexOf
(
'
The literal
'
)
>=
0
?
'
literal
'
:
'
other
'
;
}
/* __GDPR__
"textSearchComplete" : {
"reason" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
"workspaceFolderCount" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true },
"endToEndTime" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true },
"scheme" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
"error" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
}
*/
this
.
telemetryService
.
publicLog
(
'
textSearchComplete
'
,
{
reason
:
query
.
_reason
,
workspaceFolderCount
:
query
.
folderQueries
.
length
,
endToEndTime
:
endToEndTime
,
scheme
,
error
:
errorType
});
}
}
...
...
src/vs/workbench/services/search/node/textSearchAdapter.ts
浏览文件 @
7b61ee4f
...
...
@@ -15,17 +15,15 @@ export class TextSearchEngineAdapter {
constructor
(
private
query
:
ITextQuery
)
{
}
// TODO@Rob - make promise-based once the old search is gone, and I don't need them to have matching interfaces anymore
search
(
token
:
CancellationToken
,
onResult
:
(
matches
:
ISerializedFileMatch
[])
=>
void
,
onMessage
:
(
message
:
IProgress
)
=>
void
,
done
:
(
error
:
Error
,
complete
:
ISerializedSearchSuccess
)
=>
void
):
void
{
search
(
token
:
CancellationToken
,
onResult
:
(
matches
:
ISerializedFileMatch
[])
=>
void
,
onMessage
:
(
message
:
IProgress
)
=>
void
):
Promise
<
ISerializedSearchSuccess
>
{
if
(
!
this
.
query
.
folderQueries
.
length
&&
!
this
.
query
.
extraFileResources
.
length
)
{
done
(
null
,
{
return
Promise
.
resolve
(
<
ISerializedSearchSuccess
>
{
type
:
'
success
'
,
limitHit
:
false
,
stats
:
<
ITextSearchStats
>
{
type
:
'
searchProcess
'
}
});
return
;
}
const
pretendOutputChannel
=
{
...
...
@@ -34,13 +32,17 @@ export class TextSearchEngineAdapter {
}
};
const
textSearchManager
=
new
TextSearchManager
(
this
.
query
,
new
RipgrepTextSearchEngine
(
pretendOutputChannel
),
extfs
);
textSearchManager
.
search
(
matches
=>
{
onResult
(
matches
.
map
(
fileMatchToSerialized
));
},
token
)
.
then
(()
=>
done
(
null
,
{
limitHit
:
false
,
stats
:
null
,
type
:
'
success
'
}));
return
new
Promise
((
resolve
,
reject
)
=>
{
return
textSearchManager
.
search
(
matches
=>
{
onResult
(
matches
.
map
(
fileMatchToSerialized
));
},
token
)
.
then
(
()
=>
resolve
({
limitHit
:
false
,
stats
:
null
,
type
:
'
success
'
}),
reject
);
});
}
}
...
...
src/vs/workbench/services/search/node/textSearchManager.ts
浏览文件 @
7b61ee4f
...
...
@@ -128,7 +128,7 @@ export class TextSearchManager {
useIgnoreFiles
:
!
fq
.
disregardIgnoreFiles
,
useGlobalIgnoreFiles
:
!
fq
.
disregardGlobalIgnoreFiles
,
followSymlinks
:
!
fq
.
ignoreSymlinks
,
encoding
:
this
.
query
.
fileEncoding
,
encoding
:
fq
.
fileEncoding
,
maxFileSize
:
this
.
query
.
maxFileSize
,
maxResults
:
this
.
query
.
maxResults
,
previewOptions
:
this
.
query
.
previewOptions
...
...
src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts
浏览文件 @
7b61ee4f
...
...
@@ -65,29 +65,21 @@ function doLegacySearchTest(config: IRawSearch, expectedResultCount: number | Fu
}
function
doRipgrepSearchTest
(
query
:
ITextQuery
,
expectedResultCount
:
number
|
Function
):
TPromise
<
void
>
{
return
new
TPromise
<
void
>
((
resolve
,
reject
)
=>
{
let
engine
=
new
TextSearchEngineAdapter
(
query
);
let
c
=
0
;
engine
.
search
(
new
CancellationTokenSource
().
token
,
(
results
)
=>
{
if
(
results
)
{
c
+=
results
.
reduce
((
acc
,
cur
)
=>
acc
+
cur
.
numMatches
,
0
);
}
},
()
=>
{
},
(
error
)
=>
{
try
{
assert
.
ok
(
!
error
);
if
(
typeof
expectedResultCount
===
'
function
'
)
{
assert
(
expectedResultCount
(
c
));
}
else
{
assert
.
equal
(
c
,
expectedResultCount
,
`rg
${
c
}
!==
${
expectedResultCount
}
`
);
}
}
catch
(
e
)
{
reject
(
e
);
let
engine
=
new
TextSearchEngineAdapter
(
query
);
let
c
=
0
;
return
engine
.
search
(
new
CancellationTokenSource
().
token
,
(
results
)
=>
{
if
(
results
)
{
c
+=
results
.
reduce
((
acc
,
cur
)
=>
acc
+
cur
.
numMatches
,
0
);
}
},
()
=>
{
}).
then
(
()
=>
{
if
(
typeof
expectedResultCount
===
'
function
'
)
{
assert
(
expectedResultCount
(
c
));
}
else
{
assert
.
equal
(
c
,
expectedResultCount
,
`rg
${
c
}
!==
${
expectedResultCount
}
`
);
}
resolve
(
undefined
);
});
});
}
function
doSearchTest
(
query
:
ITextQuery
,
expectedResultCount
:
number
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录