Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
3673539e
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,发现更多精彩内容 >>
提交
3673539e
编写于
8月 16, 2021
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Keep search code sync when possible
上级
9ef2f072
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
23 deletion
+43
-23
src/vs/base/common/types.ts
src/vs/base/common/types.ts
+4
-0
src/vs/workbench/services/search/common/search.ts
src/vs/workbench/services/search/common/search.ts
+21
-13
src/vs/workbench/services/search/common/textSearchManager.ts
src/vs/workbench/services/search/common/textSearchManager.ts
+18
-10
未找到文件。
src/vs/base/common/types.ts
浏览文件 @
3673539e
...
...
@@ -290,3 +290,7 @@ export function NotImplementedProxy<T>(name: string): { new(): T } {
export
function
assertNever
(
value
:
never
,
message
=
'
Unreachable
'
)
{
throw
new
Error
(
message
);
}
export
function
isPromise
<
T
>
(
obj
:
unknown
):
obj
is
Promise
<
T
>
{
return
!!
obj
&&
typeof
(
obj
as
Promise
<
T
>
).
then
===
'
function
'
&&
typeof
(
obj
as
Promise
<
T
>
).
catch
===
'
function
'
;
}
src/vs/workbench/services/search/common/search.ts
浏览文件 @
3673539e
...
...
@@ -18,6 +18,7 @@ import { Event } from 'vs/base/common/event';
import
*
as
paths
from
'
vs/base/common/path
'
;
import
{
isPromiseCanceledError
}
from
'
vs/base/common/errors
'
;
import
{
TextSearchCompleteMessageType
}
from
'
vs/workbench/services/search/common/searchExtTypes
'
;
import
{
isPromise
}
from
'
vs/base/common/types
'
;
export
{
TextSearchCompleteMessageType
};
...
...
@@ -655,22 +656,29 @@ export class QueryGlobTester {
}
/**
* Guaranteed async.
* Evaluating the exclude expression is only async if it includes sibling clauses. As an optimization, avoid doing anything with Promises
* unless the expression is async.
*/
includedInQuery
(
testPath
:
string
,
basename
?:
string
,
hasSibling
?:
(
name
:
string
)
=>
boolean
|
Promise
<
boolean
>
):
Promise
<
boolean
>
{
const
excludeP
=
Promise
.
resolve
(
this
.
_parsedExcludeExpression
(
testPath
,
basename
,
hasSibling
)).
then
(
result
=>
!!
result
);
return
excludeP
.
then
(
excluded
=>
{
if
(
excluded
)
{
return
false
;
}
includedInQuery
(
testPath
:
string
,
basename
?:
string
,
hasSibling
?:
(
name
:
string
)
=>
boolean
|
Promise
<
boolean
>
):
Promise
<
boolean
>
|
boolean
{
const
excluded
=
this
.
_parsedExcludeExpression
(
testPath
,
basename
,
hasSibling
);
const
isIncluded
=
()
=>
{
return
this
.
_parsedIncludeExpression
?
Promise
.
resolve
(
this
.
_parsedIncludeExpression
(
testPath
,
basename
,
hasSibling
)).
then
(
result
=>
!!
result
)
:
Promise
.
resolve
(
true
);
}).
then
(
included
=>
{
return
included
;
});
!!
(
this
.
_parsedIncludeExpression
(
testPath
,
basename
,
hasSibling
))
:
true
;
};
if
(
isPromise
(
excluded
))
{
return
excluded
.
then
(
excluded
=>
{
if
(
excluded
)
{
return
false
;
}
return
isIncluded
();
});
}
return
isIncluded
();
}
hasSiblingExcludeClauses
():
boolean
{
...
...
src/vs/workbench/services/search/common/textSearchManager.ts
浏览文件 @
3673539e
...
...
@@ -3,17 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
path
from
'
vs/base/common/path
'
;
import
{
flatten
,
mapArrayOrNot
}
from
'
vs/base/common/arrays
'
;
import
{
CancellationToken
,
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
*
as
path
from
'
vs/base/common/path
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
isArray
,
isPromise
}
from
'
vs/base/common/types
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IExtendedExtensionSearchOptions
,
IFileMatch
,
IFolderQuery
,
IPatternInfo
,
ISearchCompleteStats
,
ITextQuery
,
ITextSearchContext
,
ITextSearchMatch
,
ITextSearchResult
,
QueryGlobTester
,
resolvePatternsForProvider
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
TextSearchProvider
,
TextSearchResult
,
TextSearchMatch
,
TextSearchComplete
,
Range
,
TextSearchOptions
,
TextSearchQuery
}
from
'
vs/workbench/services/search/common/searchExtTypes
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
isArray
}
from
'
vs/base/common/types
'
;
import
{
Range
,
TextSearchComplete
,
TextSearchMatch
,
TextSearchOptions
,
TextSearchProvider
,
TextSearchQuery
,
TextSearchResult
}
from
'
vs/workbench/services/search/common/searchExtTypes
'
;
export
interface
IFileUtils
{
readdir
:
(
resource
:
URI
)
=>
Promise
<
string
[]
>
;
...
...
@@ -131,20 +131,28 @@ export class TextSearchManager {
const
relativePath
=
resources
.
relativePath
(
folderQuery
.
folder
,
result
.
uri
);
if
(
relativePath
)
{
testingPs
.
push
(
queryTester
.
includedInQuery
(
relativePath
,
path
.
basename
(
relativePath
),
hasSibling
)
.
then
(
included
=>
{
if
(
included
)
{
// This method is only async when the exclude contains sibling clauses
const
included
=
queryTester
.
includedInQuery
(
relativePath
,
path
.
basename
(
relativePath
),
hasSibling
);
if
(
isPromise
(
included
))
{
testingPs
.
push
(
included
.
then
(
isIncluded
=>
{
if
(
isIncluded
)
{
onResult
(
result
);
}
}));
}
else
if
(
included
)
{
onResult
(
result
);
}
}
}
};
const
searchOptions
=
this
.
getSearchOptionsForFolder
(
folderQuery
);
const
result
=
await
this
.
provider
.
provideTextSearchResults
(
patternInfoToQuery
(
this
.
query
.
contentPattern
),
searchOptions
,
progress
,
token
);
await
Promise
.
all
(
testingPs
);
if
(
testingPs
.
length
)
{
await
Promise
.
all
(
testingPs
);
}
return
result
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录