Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
866bc0aa
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,发现更多精彩内容 >>
提交
866bc0aa
编写于
7月 27, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #55224 - use different cacheKeys per folder in FileIndexProvider
上级
ca35204e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
7 deletion
+32
-7
src/vs/workbench/api/node/extHostSearch.fileIndex.ts
src/vs/workbench/api/node/extHostSearch.fileIndex.ts
+30
-6
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+2
-1
未找到文件。
src/vs/workbench/api/node/extHostSearch.fileIndex.ts
浏览文件 @
866bc0aa
...
...
@@ -395,6 +395,8 @@ export class FileIndexSearchManager {
private
caches
:
{
[
cacheKey
:
string
]:
Cache
;
}
=
Object
.
create
(
null
);
private
readonly
folderCacheKeys
=
new
Map
<
string
,
Set
<
string
>>
();
public
fileSearch
(
config
:
ISearchQuery
,
provider
:
vscode
.
FileIndexProvider
,
onBatch
:
(
matches
:
IFileMatch
[])
=>
void
):
TPromise
<
ISearchCompleteStats
>
{
if
(
config
.
sortByScore
)
{
let
sortedSearch
=
this
.
trySortedSearchFromCache
(
config
);
...
...
@@ -430,13 +432,25 @@ export class FileIndexSearchManager {
});
}
private
getFolderCacheKey
(
config
:
ISearchQuery
):
string
{
const
uri
=
config
.
folderQueries
[
0
].
folder
.
toString
();
const
folderCacheKey
=
config
.
cacheKey
&&
`
${
uri
}
_
${
config
.
cacheKey
}
`
;
if
(
!
this
.
folderCacheKeys
.
get
(
config
.
cacheKey
))
{
this
.
folderCacheKeys
.
set
(
config
.
cacheKey
,
new
Set
());
}
this
.
folderCacheKeys
.
get
(
config
.
cacheKey
).
add
(
folderCacheKey
);
return
folderCacheKey
;
}
private
rawMatchToSearchItem
(
match
:
IInternalFileMatch
):
IFileMatch
{
return
{
resource
:
match
.
original
||
resources
.
joinPath
(
match
.
base
,
match
.
relativePath
)
};
}
private
doSortedSearch
(
engine
:
FileIndexSearchEngine
,
config
:
I
Raw
SearchQuery
):
TPromise
<
IInternalSearchComplete
>
{
private
doSortedSearch
(
engine
:
FileIndexSearchEngine
,
config
:
ISearchQuery
):
TPromise
<
IInternalSearchComplete
>
{
let
searchPromise
:
TPromise
<
void
>
;
let
allResultsPromise
=
new
TPromise
<
IInternalSearchComplete
>
((
c
,
e
)
=>
{
searchPromise
=
this
.
doSearch
(
engine
).
then
(
c
,
e
);
...
...
@@ -444,9 +458,10 @@ export class FileIndexSearchManager {
searchPromise
.
cancel
();
});
const
folderCacheKey
=
this
.
getFolderCacheKey
(
config
);
let
cache
:
Cache
;
if
(
config
.
c
acheKey
)
{
cache
=
this
.
getOrCreateCache
(
config
.
c
acheKey
);
if
(
folderC
acheKey
)
{
cache
=
this
.
getOrCreateCache
(
folderC
acheKey
);
cache
.
resultsToSearchCache
[
config
.
filePattern
]
=
allResultsPromise
;
allResultsPromise
.
then
(
null
,
err
=>
{
delete
cache
.
resultsToSearchCache
[
config
.
filePattern
];
...
...
@@ -480,8 +495,9 @@ export class FileIndexSearchManager {
return
this
.
caches
[
cacheKey
]
=
new
Cache
();
}
private
trySortedSearchFromCache
(
config
:
IRawSearchQuery
):
TPromise
<
IInternalSearchComplete
>
{
const
cache
=
config
.
cacheKey
&&
this
.
caches
[
config
.
cacheKey
];
private
trySortedSearchFromCache
(
config
:
ISearchQuery
):
TPromise
<
IInternalSearchComplete
>
{
const
folderCacheKey
=
this
.
getFolderCacheKey
(
config
);
const
cache
=
folderCacheKey
&&
this
.
caches
[
folderCacheKey
];
if
(
!
cache
)
{
return
undefined
;
}
...
...
@@ -596,7 +612,15 @@ export class FileIndexSearchManager {
}
public
clearCache
(
cacheKey
:
string
):
TPromise
<
void
>
{
delete
this
.
caches
[
cacheKey
];
if
(
!
this
.
folderCacheKeys
.
has
(
cacheKey
))
{
return
TPromise
.
wrap
(
undefined
);
}
const
expandedKeys
=
this
.
folderCacheKeys
.
get
(
cacheKey
);
expandedKeys
.
forEach
(
key
=>
delete
this
.
caches
[
key
]);
this
.
folderCacheKeys
.
delete
(
cacheKey
);
return
TPromise
.
as
(
undefined
);
}
...
...
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
866bc0aa
...
...
@@ -96,7 +96,8 @@ export class ExtHostSearch implements ExtHostSearchShape {
}
$clearCache
(
cacheKey
:
string
):
TPromise
<
void
>
{
// Only relevant to file index search
// Actually called once per provider.
// Only relevant to file index search.
return
this
.
_fileIndexSearchManager
.
clearCache
(
cacheKey
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录