Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
824a3e92
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,发现更多精彩内容 >>
提交
824a3e92
编写于
7月 03, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Search provider - remove absolute path checks from extHostSearch to match fileSearch.ts
上级
fdf27274
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
68 deletion
+26
-68
extensions/search-rg/src/cachedSearchProvider.ts
extensions/search-rg/src/cachedSearchProvider.ts
+0
-4
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+26
-64
未找到文件。
extensions/search-rg/src/cachedSearchProvider.ts
浏览文件 @
824a3e92
...
...
@@ -113,10 +113,6 @@ export class CachedSearchProvider {
}
private
getResultsFromCache
(
cache
:
Cache
,
searchValue
:
string
,
onResult
:
(
results
:
IInternalFileMatch
)
=>
void
):
Promise
<
[
IInternalFileMatch
[],
CacheStats
]
>
{
if
(
path
.
isAbsolute
(
searchValue
))
{
return
null
;
// bypass cache if user looks up an absolute path where matching goes directly on disk
}
// Find cache entries by prefix of search value
const
hasPathSep
=
searchValue
.
indexOf
(
path
.
sep
)
>=
0
;
let
cached
:
CacheEntry
<
IInternalFileMatch
>
;
...
...
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
824a3e92
...
...
@@ -540,52 +540,36 @@ class FileSearchEngine {
};
// Support that the file pattern is a full path to a file that exists
this
.
checkFilePatternAbsoluteMatch
().
then
(({
exists
,
size
})
=>
{
if
(
this
.
isCanceled
)
{
return
resolve
({
isLimitHit
:
this
.
isLimitHit
});
}
if
(
this
.
isCanceled
)
{
return
resolve
({
isLimitHit
:
this
.
isLimitHit
});
}
// Report result from file pattern if matching
if
(
exists
)
{
onResult
({
base
:
URI
.
file
(
this
.
filePattern
),
basename
:
path
.
basename
(
this
.
filePattern
),
size
// For each extra file
if
(
this
.
config
.
extraFileResources
)
{
this
.
config
.
extraFileResources
.
forEach
(
extraFile
=>
{
const
extraFileStr
=
extraFile
.
toString
();
// ?
const
basename
=
path
.
basename
(
extraFileStr
);
if
(
this
.
globalExcludePattern
&&
this
.
globalExcludePattern
(
extraFileStr
,
basename
))
{
return
;
// excluded
}
// File: Check for match on file pattern and include pattern
this
.
matchFile
(
onResult
,
{
base
:
extraFile
,
basename
});
});
}
// Optimization: a match on an absolute path is a good result and we do not
// continue walking the entire root paths array for other matches because
// it is very unlikely that another file would match on the full absolute path
return
resolve
({
isLimitHit
:
this
.
isLimitHit
});
}
// For each extra file
if
(
this
.
config
.
extraFileResources
)
{
this
.
config
.
extraFileResources
.
forEach
(
extraFile
=>
{
const
extraFileStr
=
extraFile
.
toString
();
// ?
const
basename
=
path
.
basename
(
extraFileStr
);
if
(
this
.
globalExcludePattern
&&
this
.
globalExcludePattern
(
extraFileStr
,
basename
))
{
return
;
// excluded
}
// File: Check for match on file pattern and include pattern
this
.
matchFile
(
onResult
,
{
base
:
extraFile
,
basename
});
});
}
// For each root folder
PPromise
.
join
(
folderQueries
.
map
(
fq
=>
{
return
this
.
searchInFolder
(
fq
).
then
(
null
,
null
,
onResult
);
})).
then
(()
=>
{
resolve
({
isLimitHit
:
this
.
isLimitHit
});
},
(
errs
:
Error
[])
=>
{
const
errMsg
=
errs
.
map
(
err
=>
toErrorMessage
(
err
))
.
filter
(
msg
=>
!!
msg
)[
0
];
// For each root folder
PPromise
.
join
(
folderQueries
.
map
(
fq
=>
{
return
this
.
searchInFolder
(
fq
).
then
(
null
,
null
,
onResult
);
})).
then
(()
=>
{
resolve
({
isLimitHit
:
this
.
isLimitHit
});
},
(
errs
:
Error
[])
=>
{
const
errMsg
=
errs
.
map
(
err
=>
toErrorMessage
(
err
))
.
filter
(
msg
=>
!!
msg
)[
0
];
reject
(
new
Error
(
errMsg
));
});
reject
(
new
Error
(
errMsg
));
});
});
}
...
...
@@ -745,28 +729,6 @@ class FileSearchEngine {
matchDirectory
(
rootEntries
);
}
/**
* Return whether the file pattern is an absolute path to a file that exists.
* TODO@roblou delete to match fileSearch.ts
*/
private
checkFilePatternAbsoluteMatch
():
TPromise
<
{
exists
:
boolean
,
size
?:
number
}
>
{
if
(
!
this
.
filePattern
||
!
path
.
isAbsolute
(
this
.
filePattern
))
{
return
TPromise
.
wrap
({
exists
:
false
});
}
return
this
.
_pfs
.
stat
(
this
.
filePattern
)
.
then
(
stat
=>
{
return
{
exists
:
!
stat
.
isDirectory
(),
size
:
stat
.
size
};
},
err
=>
{
return
{
exists
:
false
};
});
}
private
checkFilePatternRelativeMatch
(
base
:
URI
):
TPromise
<
{
exists
:
boolean
,
size
?:
number
}
>
{
if
(
!
this
.
filePattern
||
path
.
isAbsolute
(
this
.
filePattern
)
||
base
.
scheme
!==
'
file
'
)
{
return
TPromise
.
wrap
({
exists
:
false
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录