Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a015dc90
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,发现更多精彩内容 >>
提交
a015dc90
编写于
5月 25, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EH search - fix search providers using non-file schemes
上级
951c98ee
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
29 deletion
+35
-29
src/vs/base/common/resources.ts
src/vs/base/common/resources.ts
+7
-0
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+24
-25
src/vs/workbench/services/search/node/searchService.ts
src/vs/workbench/services/search/node/searchService.ts
+4
-4
未找到文件。
src/vs/base/common/resources.ts
浏览文件 @
a015dc90
...
...
@@ -52,6 +52,13 @@ export function dirname(resource: uri): uri {
});
}
export
function
joinPath
(
resource
:
uri
,
pathFragment
:
string
):
uri
{
const
joinedPath
=
paths
.
join
(
resource
.
path
||
'
/
'
,
pathFragment
);
return
resource
.
with
({
path
:
joinedPath
});
}
export
function
distinctParents
<
T
>
(
items
:
T
[],
resourceAccessor
:
(
item
:
T
)
=>
uri
):
T
[]
{
const
distinctParents
:
T
[]
=
[];
for
(
let
i
=
0
;
i
<
items
.
length
;
i
++
)
{
...
...
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
a015dc90
...
...
@@ -18,6 +18,7 @@ import { ICachedSearchStats, IFileMatch, IFolderQuery, IPatternInfo, IRawSearchQ
import
*
as
vscode
from
'
vscode
'
;
import
{
ExtHostSearchShape
,
IMainContext
,
MainContext
,
MainThreadSearchShape
}
from
'
./extHost.protocol
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
joinPath
}
from
'
vs/base/common/resources
'
;
type
OneOrMore
<
T
>
=
T
|
T
[];
...
...
@@ -151,7 +152,7 @@ class TextSearchResultsCollector {
}
if
(
!
this
.
_currentFileMatch
)
{
const
resource
=
URI
.
file
(
path
.
join
(
this
.
folderQueries
[
folderIdx
].
folder
.
fsPath
,
data
.
path
)
);
const
resource
=
joinPath
(
this
.
folderQueries
[
folderIdx
].
folder
,
data
.
path
);
this
.
_currentFileMatch
=
{
resource
,
lineMatches
:
[]
...
...
@@ -271,7 +272,7 @@ class BatchedCollector<T> {
}
interface
IDirectoryEntry
{
base
:
string
;
base
:
URI
;
relativePath
:
string
;
basename
:
string
;
}
...
...
@@ -282,8 +283,8 @@ interface IDirectoryTree {
}
interface
IInternalFileMatch
{
base
?:
string
;
relativePath
:
string
;
// Not necessarily relative... extraFiles put an absolute path here. Rename.
base
:
URI
;
relativePath
?:
string
;
// Not present for extraFiles or absolute path matches
basename
:
string
;
size
?:
number
;
}
...
...
@@ -433,9 +434,9 @@ class TextSearchEngine {
const
testingPs
=
[];
const
progress
=
{
report
:
(
result
:
vscode
.
TextSearchResult
)
=>
{
const
siblingFn
=
()
=>
{
const
siblingFn
=
folderQuery
.
folder
.
scheme
===
'
file
'
&&
(
()
=>
{
return
this
.
readdir
(
path
.
dirname
(
path
.
join
(
folderQuery
.
folder
.
fsPath
,
result
.
path
)));
};
}
)
;
testingPs
.
push
(
queryTester
.
includedInQuery
(
result
.
path
,
path
.
basename
(
result
.
path
),
siblingFn
)
...
...
@@ -558,7 +559,7 @@ class FileSearchEngine {
// Report result from file pattern if matching
if
(
exists
)
{
onResult
({
relativePath
:
this
.
filePattern
,
base
:
URI
.
file
(
this
.
filePattern
)
,
basename
:
path
.
basename
(
this
.
filePattern
),
size
});
...
...
@@ -572,15 +573,15 @@ class FileSearchEngine {
// For each extra file
if
(
this
.
config
.
extraFileResources
)
{
this
.
config
.
extraFileResources
.
map
(
uri
=>
uri
.
toString
())
.
forEach
(
extraFilePath
=>
{
const
basename
=
path
.
basename
(
extraFile
Path
);
if
(
this
.
globalExcludePattern
&&
this
.
globalExcludePattern
(
extraFile
Path
,
basename
))
{
.
forEach
(
extraFile
=>
{
const
extraFileStr
=
extraFile
.
toString
();
// ?
const
basename
=
path
.
basename
(
extraFile
Str
);
if
(
this
.
globalExcludePattern
&&
this
.
globalExcludePattern
(
extraFile
Str
,
basename
))
{
return
;
// excluded
}
// File: Check for match on file pattern and include pattern
this
.
matchFile
(
onResult
,
{
relativePath
:
extraFilePath
/* no workspace relative path */
,
basename
});
this
.
matchFile
(
onResult
,
{
base
:
extraFile
,
basename
});
});
}
...
...
@@ -604,7 +605,6 @@ class FileSearchEngine {
let
cancellation
=
new
CancellationTokenSource
();
return
new
PPromise
((
resolve
,
reject
,
onResult
)
=>
{
const
options
=
this
.
getSearchOptionsForFolder
(
fq
);
const
folderStr
=
fq
.
folder
.
fsPath
;
let
filePatternSeen
=
false
;
const
tree
=
this
.
initDirectoryTree
();
...
...
@@ -616,20 +616,19 @@ class FileSearchEngine {
return
;
}
// This is slow...
if
(
noSiblingsClauses
)
{
if
(
relativePath
===
this
.
filePattern
)
{
filePatternSeen
=
true
;
}
const
basename
=
path
.
basename
(
relativePath
);
this
.
matchFile
(
onResult
,
{
base
:
f
olderSt
r
,
relativePath
,
basename
});
this
.
matchFile
(
onResult
,
{
base
:
f
q
.
folde
r
,
relativePath
,
basename
});
return
;
}
// TODO: Optimize siblings clauses with ripgrep here.
this
.
addDirectoryEntries
(
tree
,
f
olderSt
r
,
relativePath
,
onResult
);
this
.
addDirectoryEntries
(
tree
,
f
q
.
folde
r
,
relativePath
,
onResult
);
};
new
TPromise
(
resolve
=>
process
.
nextTick
(
resolve
))
...
...
@@ -646,10 +645,10 @@ class FileSearchEngine {
if
(
noSiblingsClauses
&&
this
.
isLimitHit
)
{
if
(
!
filePatternSeen
)
{
// If the limit was hit, check whether filePattern is an exact relative match because it must be included
return
this
.
checkFilePatternRelativeMatch
(
f
olderSt
r
).
then
(({
exists
,
size
})
=>
{
return
this
.
checkFilePatternRelativeMatch
(
f
q
.
folde
r
).
then
(({
exists
,
size
})
=>
{
if
(
exists
)
{
onResult
({
base
:
f
olderSt
r
,
base
:
f
q
.
folde
r
,
relativePath
:
this
.
filePattern
,
basename
:
path
.
basename
(
this
.
filePattern
),
});
...
...
@@ -658,7 +657,7 @@ class FileSearchEngine {
}
}
this
.
matchDirectoryTree
(
tree
,
folderStr
,
queryTester
,
onResult
);
this
.
matchDirectoryTree
(
tree
,
queryTester
,
onResult
);
return
null
;
}).
then
(
()
=>
{
...
...
@@ -694,7 +693,7 @@ class FileSearchEngine {
return
tree
;
}
private
addDirectoryEntries
({
pathToEntries
}:
IDirectoryTree
,
base
:
string
,
relativeFile
:
string
,
onResult
:
(
result
:
IInternalFileMatch
)
=>
void
)
{
private
addDirectoryEntries
({
pathToEntries
}:
IDirectoryTree
,
base
:
URI
,
relativeFile
:
string
,
onResult
:
(
result
:
IInternalFileMatch
)
=>
void
)
{
// Support relative paths to files from a root resource (ignores excludes)
if
(
relativeFile
===
this
.
filePattern
)
{
const
basename
=
path
.
basename
(
this
.
filePattern
);
...
...
@@ -719,7 +718,7 @@ class FileSearchEngine {
add
(
relativeFile
);
}
private
matchDirectoryTree
({
rootEntries
,
pathToEntries
}:
IDirectoryTree
,
rootFolder
:
string
,
queryTester
:
QueryGlobTester
,
onResult
:
(
result
:
IInternalFileMatch
)
=>
void
)
{
private
matchDirectoryTree
({
rootEntries
,
pathToEntries
}:
IDirectoryTree
,
queryTester
:
QueryGlobTester
,
onResult
:
(
result
:
IInternalFileMatch
)
=>
void
)
{
const
self
=
this
;
const
filePattern
=
this
.
filePattern
;
function
matchDirectory
(
entries
:
IDirectoryEntry
[])
{
...
...
@@ -794,12 +793,12 @@ class FileSearchEngine {
});
}
private
checkFilePatternRelativeMatch
(
base
Path
:
string
):
TPromise
<
{
exists
:
boolean
,
size
?:
number
}
>
{
if
(
!
this
.
filePattern
||
path
.
isAbsolute
(
this
.
filePattern
))
{
private
checkFilePatternRelativeMatch
(
base
:
URI
):
TPromise
<
{
exists
:
boolean
,
size
?:
number
}
>
{
if
(
!
this
.
filePattern
||
path
.
isAbsolute
(
this
.
filePattern
)
||
base
.
scheme
!==
'
file
'
)
{
return
TPromise
.
wrap
({
exists
:
false
});
}
const
absolutePath
=
path
.
join
(
basePath
,
this
.
filePattern
);
const
absolutePath
=
path
.
join
(
base
.
fs
Path
,
this
.
filePattern
);
return
this
.
_pfs
.
stat
(
absolutePath
).
then
(
stat
=>
{
return
{
exists
:
!
stat
.
isDirectory
(),
...
...
@@ -894,7 +893,7 @@ class FileSearchManager {
private
rawMatchToSearchItem
(
match
:
IInternalFileMatch
):
IFileMatch
{
return
{
resource
:
URI
.
file
(
match
.
base
?
path
.
join
(
match
.
base
,
match
.
relativePath
)
:
match
.
relativePath
)
resource
:
joinPath
(
match
.
base
,
match
.
relativePath
)
};
}
...
...
src/vs/workbench/services/search/node/searchService.ts
浏览文件 @
a015dc90
...
...
@@ -122,14 +122,14 @@ export class SearchService implements ISearchService {
if
(
this
.
searchProvider
.
length
)
{
return
TPromise
.
join
(
this
.
searchProvider
.
map
(
p
=>
searchWithProvider
(
p
)))
.
then
(
complete
=>
{
co
nst
first
:
ISearchComplete
=
complete
[
0
]
;
if
(
!
first
)
{
co
mplete
=
complete
.
filter
(
c
=>
!!
c
)
;
if
(
!
complete
.
length
)
{
return
null
;
}
return
<
ISearchComplete
>
{
limitHit
:
first
&&
first
.
limitHit
,
stats
:
first
.
stats
,
limitHit
:
complete
[
0
]
&&
complete
[
0
]
.
limitHit
,
stats
:
complete
[
0
]
.
stats
,
results
:
arrays
.
flatten
(
complete
.
map
(
c
=>
c
.
results
))
};
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录