Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d0b06a63
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,体验更适合开发者的 AI 搜索 >>
提交
d0b06a63
编写于
5月 20, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change EH search back to use URIs between EH and renderer process
上级
a521c01d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
32 deletion
+26
-32
src/vs/platform/search/common/search.ts
src/vs/platform/search/common/search.ts
+2
-7
src/vs/workbench/api/electron-browser/mainThreadSearch.ts
src/vs/workbench/api/electron-browser/mainThreadSearch.ts
+3
-11
src/vs/workbench/api/node/extHostSearch.ts
src/vs/workbench/api/node/extHostSearch.ts
+8
-8
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
...workbench/test/electron-browser/api/extHostSearch.test.ts
+13
-6
未找到文件。
src/vs/platform/search/common/search.ts
浏览文件 @
d0b06a63
...
...
@@ -104,17 +104,12 @@ export interface IPatternInfo {
isSmartCase
?:
boolean
;
}
export
interface
IFileMatch
<
U
=
uri
>
{
export
interface
IFileMatch
<
U
extends
UriComponents
=
uri
>
{
resource
?:
U
;
lineMatches
?:
ILineMatch
[];
}
export
interface
IPathInFolder
{
folderIdx
:
number
;
relativePath
:
string
;
}
export
type
IRawFileMatch2
=
IFileMatch
<
IPathInFolder
>
;
export
type
IRawFileMatch2
=
IFileMatch
<
UriComponents
>
;
export
interface
ILineMatch
{
preview
:
string
;
...
...
src/vs/workbench/api/electron-browser/mainThreadSearch.ts
浏览文件 @
d0b06a63
...
...
@@ -4,13 +4,12 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
path
from
'
path
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
PPromise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IFileMatch
,
ISearchComplete
,
ISearchProgressItem
,
ISearchQuery
,
ISearchResultProvider
,
ISearchService
,
QueryType
,
IRawFileMatch2
,
ISearchCompleteStats
,
IFolderQuery
}
from
'
vs/platform/search/common/search
'
;
import
{
IFileMatch
,
ISearchComplete
,
ISearchProgressItem
,
ISearchQuery
,
ISearchResultProvider
,
ISearchService
,
QueryType
,
IRawFileMatch2
,
ISearchCompleteStats
}
from
'
vs/platform/search/common/search
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
ExtHostContext
,
ExtHostSearchShape
,
IExtHostContext
,
MainContext
,
MainThreadSearchShape
}
from
'
../node/extHost.protocol
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
@@ -58,7 +57,6 @@ class SearchOperation {
constructor
(
readonly
progress
:
(
match
:
IFileMatch
)
=>
any
,
readonly
folders
:
IFolderQuery
[],
readonly
id
:
number
=
++
SearchOperation
.
_idPool
,
readonly
matches
=
new
Map
<
string
,
IFileMatch
>
()
)
{
...
...
@@ -112,7 +110,7 @@ class RemoteSearchProvider implements ISearchResultProvider {
return
new
PPromise
((
resolve
,
reject
,
report
)
=>
{
const
search
=
new
SearchOperation
(
report
,
query
.
folderQueries
);
const
search
=
new
SearchOperation
(
report
);
this
.
_searches
.
set
(
search
.
id
,
search
);
outer
=
query
.
type
===
QueryType
.
File
...
...
@@ -142,14 +140,8 @@ class RemoteSearchProvider implements ISearchResultProvider {
const
searchOp
=
this
.
_searches
.
get
(
session
);
if
(
Array
.
isArray
(
dataOrUri
))
{
dataOrUri
.
forEach
(
m
=>
{
const
folderQuery
=
searchOp
.
folders
[
m
.
resource
.
folderIdx
];
if
(
!
folderQuery
)
{
return
;
}
const
fullUri
=
URI
.
file
(
path
.
join
(
folderQuery
.
folder
.
fsPath
,
m
.
resource
.
relativePath
));
searchOp
.
addMatch
({
resource
:
fullUri
,
resource
:
URI
.
revive
(
m
.
resource
)
,
lineMatches
:
m
.
lineMatches
});
});
...
...
src/vs/workbench/api/node/extHostSearch.ts
浏览文件 @
d0b06a63
...
...
@@ -14,7 +14,7 @@ import * as strings from 'vs/base/common/strings';
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
PPromise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IItemAccessor
,
ScorerCache
,
compareItemsByScore
,
prepareQuery
}
from
'
vs/base/parts/quickopen/common/quickOpenScorer
'
;
import
{
ICachedSearchStats
,
I
RawFileMatch2
,
IFolderQuery
,
IPatternInfo
,
IRawSearchQuery
,
ISearchQuery
,
ISearchCompleteStats
,
IFileMatch
}
from
'
vs/platform/search/common/search
'
;
import
{
ICachedSearchStats
,
I
FileMatch
,
IFolderQuery
,
IPatternInfo
,
IRawSearchQuery
,
ISearchQuery
,
ISearchCompleteStats
,
IRawFileMatch2
}
from
'
vs/platform/search/common/search
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
ExtHostSearchShape
,
IMainContext
,
MainContext
,
MainThreadSearchShape
}
from
'
./extHost.protocol
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
...
...
@@ -133,9 +133,11 @@ function reviveFolderQuery(rawFolderQuery: IFolderQuery<UriComponents>): IFolder
class
TextSearchResultsCollector
{
private
_batchedCollector
:
BatchedCollector
<
IRawFileMatch2
>
;
private
_currentFolderIdx
:
number
;
private
_currentRelativePath
:
string
;
private
_currentFileMatch
:
IRawFileMatch2
;
constructor
(
private
_onResult
:
(
result
:
IRawFileMatch2
[])
=>
void
)
{
constructor
(
private
folderQueries
:
IFolderQuery
[],
private
_onResult
:
(
result
:
IRawFileMatch2
[])
=>
void
)
{
this
.
_batchedCollector
=
new
BatchedCollector
<
IRawFileMatch2
>
(
512
,
items
=>
this
.
sendItems
(
items
));
}
...
...
@@ -143,17 +145,15 @@ class TextSearchResultsCollector {
// Collects TextSearchResults into IInternalFileMatches and collates using BatchedCollector.
// This is efficient for ripgrep which sends results back one file at a time. It wouldn't be efficient for other search
// providers that send results in random order. We could do this step afterwards instead.
if
(
this
.
_currentFileMatch
&&
(
this
.
_currentF
ileMatch
.
resource
.
folderIdx
!==
folderIdx
||
this
.
_currentFileMatch
.
resource
.
r
elativePath
!==
data
.
path
))
{
if
(
this
.
_currentFileMatch
&&
(
this
.
_currentF
olderIdx
!==
folderIdx
||
this
.
_currentR
elativePath
!==
data
.
path
))
{
this
.
pushToCollector
();
this
.
_currentFileMatch
=
null
;
}
if
(
!
this
.
_currentFileMatch
)
{
const
resource
=
URI
.
file
(
path
.
join
(
this
.
folderQueries
[
folderIdx
].
folder
.
fsPath
,
data
.
path
));
this
.
_currentFileMatch
=
{
resource
:
{
folderIdx
,
relativePath
:
data
.
path
},
resource
,
lineMatches
:
[]
};
}
...
...
@@ -393,7 +393,7 @@ class TextSearchEngine {
const
folderQueries
=
this
.
config
.
folderQueries
;
return
new
PPromise
<
{
limitHit
:
boolean
},
IRawFileMatch2
[]
>
((
resolve
,
reject
,
_onResult
)
=>
{
this
.
collector
=
new
TextSearchResultsCollector
(
_onResult
);
this
.
collector
=
new
TextSearchResultsCollector
(
this
.
config
.
folderQueries
,
_onResult
);
const
onResult
=
(
match
:
vscode
.
TextSearchResult
,
folderIdx
:
number
)
=>
{
if
(
this
.
isCanceled
)
{
...
...
src/vs/workbench/test/electron-browser/api/extHostSearch.test.ts
浏览文件 @
d0b06a63
...
...
@@ -9,7 +9,7 @@ import * as path from 'path';
import
*
as
extfs
from
'
vs/base/node/extfs
'
;
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IRawFileMatch2
,
IRawSearchQuery
,
QueryType
,
ISearchQuery
,
IPatternInfo
}
from
'
vs/platform/search/common/search
'
;
import
{
IRawFileMatch2
,
IRawSearchQuery
,
QueryType
,
ISearchQuery
,
IPatternInfo
,
IFileMatch
}
from
'
vs/platform/search/common/search
'
;
import
{
MainContext
,
MainThreadSearchShape
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
ExtHostSearch
}
from
'
vs/workbench/api/node/extHostSearch
'
;
import
{
TestRPCProtocol
}
from
'
vs/workbench/test/electron-browser/api/testRPCProtocol
'
;
...
...
@@ -78,7 +78,7 @@ suite('ExtHostSearch', () => {
return
(
<
UriComponents
[]
>
mockMainThreadSearch
.
results
).
map
(
r
=>
URI
.
revive
(
r
));
}
async
function
runTextSearch
(
pattern
:
IPatternInfo
,
query
:
IRawSearchQuery
,
cancel
=
false
):
TPromise
<
I
RawFileMatch2
[]
>
{
async
function
runTextSearch
(
pattern
:
IPatternInfo
,
query
:
IRawSearchQuery
,
cancel
=
false
):
TPromise
<
I
FileMatch
[]
>
{
try
{
const
p
=
extHostSearch
.
$provideTextSearchResults
(
mockMainThreadSearch
.
lastHandle
,
0
,
pattern
,
query
);
if
(
cancel
)
{
...
...
@@ -95,7 +95,12 @@ suite('ExtHostSearch', () => {
}
await
rpcProtocol
.
sync
();
return
<
IRawFileMatch2
[]
>
mockMainThreadSearch
.
results
;
return
(
<
IRawFileMatch2
[]
>
mockMainThreadSearch
.
results
).
map
(
r
=>
({
...
r
,
...{
resource
:
URI
.
revive
(
r
.
resource
)
}
}));
}
setup
(()
=>
{
...
...
@@ -114,7 +119,7 @@ suite('ExtHostSearch', () => {
return
rpcProtocol
.
sync
();
});
const
rootFolderA
=
URI
.
file
(
'
/foo/bar
'
);
const
rootFolderA
=
URI
.
file
(
'
/foo/bar
1
'
);
const
rootFolderB
=
URI
.
file
(
'
/foo/bar2
'
);
// const rootFolderC = URI.file('/foo/bar3');
...
...
@@ -647,15 +652,17 @@ suite('ExtHostSearch', () => {
};
}
function
assertResults
(
actual
:
I
RawFileMatch2
[],
expected
:
vscode
.
TextSearchResult
[])
{
function
assertResults
(
actual
:
I
FileMatch
[],
expected
:
vscode
.
TextSearchResult
[])
{
const
actualTextSearchResults
:
vscode
.
TextSearchResult
[]
=
[];
for
(
let
fileMatch
of
actual
)
{
// Make relative
const
relativePath
=
fileMatch
.
resource
.
fsPath
.
substr
(
rootFolderA
.
fsPath
.
length
+
1
);
for
(
let
lineMatch
of
fileMatch
.
lineMatches
)
{
for
(
let
[
offset
,
length
]
of
lineMatch
.
offsetAndLengths
)
{
actualTextSearchResults
.
push
({
preview
:
{
text
:
lineMatch
.
preview
,
match
:
null
},
range
:
new
Range
(
lineMatch
.
lineNumber
,
offset
,
lineMatch
.
lineNumber
,
length
+
offset
),
path
:
fileMatch
.
resource
.
relativePath
path
:
relativePath
});
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录