Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
36d5e046
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,发现更多精彩内容 >>
提交
36d5e046
编写于
10月 25, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use combined search results for matches from editor, too
上级
7397ec97
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
25 deletion
+56
-25
src/vs/workbench/parts/search/common/searchModel.ts
src/vs/workbench/parts/search/common/searchModel.ts
+4
-10
src/vs/workbench/services/search/common/searchHelpers.ts
src/vs/workbench/services/search/common/searchHelpers.ts
+46
-0
src/vs/workbench/services/search/node/search.ts
src/vs/workbench/services/search/node/search.ts
+1
-1
src/vs/workbench/services/search/node/searchService.ts
src/vs/workbench/services/search/node/searchService.ts
+5
-14
未找到文件。
src/vs/workbench/parts/search/common/searchModel.ts
浏览文件 @
36d5e046
...
...
@@ -21,11 +21,12 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import
{
createDecorator
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IProgressRunner
}
from
'
vs/platform/progress/common/progress
'
;
import
{
ReplacePattern
}
from
'
vs/platform/search/common/replace
'
;
import
{
IFileMatch
,
IPatternInfo
,
ISearchComplete
,
ISearchProgressItem
,
ISearchService
,
ITextQuery
,
ITextSearchPreviewOptions
,
ITextSearchResult
,
ITextSearchStats
,
TextSearchResult
}
from
'
vs/platform/search/common/search
'
;
import
{
IFileMatch
,
IPatternInfo
,
ISearchComplete
,
ISearchProgressItem
,
ISearchService
,
ITextQuery
,
ITextSearchPreviewOptions
,
ITextSearchResult
,
ITextSearchStats
}
from
'
vs/platform/search/common/search
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
overviewRulerFindMatchForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
themeColorFromId
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IReplaceService
}
from
'
vs/workbench/parts/search/common/replace
'
;
import
{
editorMatchesToTextSearchResults
}
from
'
vs/workbench/services/search/common/searchHelpers
'
;
export
class
Match
{
...
...
@@ -241,8 +242,8 @@ export class FileMatch extends Disposable {
}
private
updateMatches
(
matches
:
FindMatch
[],
modelChange
:
boolean
)
{
matches
.
forEach
(
m
=>
{
const
textSearchResult
=
editorMatchToTextSearchResult
(
m
,
this
.
_model
,
this
.
_previewOptions
);
const
textSearchResults
=
editorMatchesToTextSearchResults
(
matches
,
this
.
_model
,
this
.
_previewOptions
);
textSearchResults
.
forEach
(
textSearchResult
=>
{
const
match
=
new
Match
(
this
,
textSearchResult
);
if
(
!
this
.
_removedMatches
.
has
(
match
.
id
()))
{
...
...
@@ -1009,13 +1010,6 @@ export class RangeHighlightDecorations implements IDisposable {
});
}
export
function
editorMatchToTextSearchResult
(
match
:
FindMatch
,
model
:
ITextModel
,
previewOptions
:
ITextSearchPreviewOptions
):
TextSearchResult
{
return
new
TextSearchResult
(
model
.
getLineContent
(
match
.
range
.
startLineNumber
),
new
Range
(
match
.
range
.
startLineNumber
-
1
,
match
.
range
.
startColumn
-
1
,
match
.
range
.
endLineNumber
-
1
,
match
.
range
.
endColumn
-
1
),
previewOptions
);
}
function
textSearchResultToMatches
(
rawMatch
:
ITextSearchResult
,
fileMatch
:
FileMatch
):
Match
[]
{
if
(
Array
.
isArray
(
rawMatch
.
ranges
))
{
return
rawMatch
.
ranges
.
map
((
r
,
i
)
=>
{
...
...
src/vs/workbench/services/search/common/searchHelpers.ts
0 → 100644
浏览文件 @
36d5e046
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
FindMatch
,
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
ITextSearchPreviewOptions
,
TextSearchResult
}
from
'
vs/platform/search/common/search
'
;
function
editorMatchToTextSearchResult
(
matches
:
FindMatch
[],
model
:
ITextModel
,
previewOptions
?:
ITextSearchPreviewOptions
):
TextSearchResult
{
const
firstLine
=
matches
[
0
].
range
.
startLineNumber
;
const
lastLine
=
matches
[
matches
.
length
-
1
].
range
.
endLineNumber
;
const
lineTexts
:
string
[]
=
[];
const
numLines
=
previewOptions
?
previewOptions
.
matchLines
:
Number
.
MAX_VALUE
;
for
(
let
i
=
firstLine
;
i
<=
lastLine
&&
(
i
-
firstLine
)
<
numLines
;
i
++
)
{
lineTexts
.
push
(
model
.
getLineContent
(
i
));
}
return
new
TextSearchResult
(
lineTexts
.
join
(
'
\n
'
),
matches
.
map
(
m
=>
new
Range
(
m
.
range
.
startLineNumber
-
1
,
m
.
range
.
startColumn
-
1
,
m
.
range
.
endLineNumber
-
1
,
m
.
range
.
endColumn
-
1
)),
previewOptions
);
}
/**
* Combine a set of FindMatches into a set of TextSearchResults. They should be grouped by matches that start on the same line that the previous match ends on.
*/
export
function
editorMatchesToTextSearchResults
(
matches
:
FindMatch
[],
model
:
ITextModel
,
previewOptions
?:
ITextSearchPreviewOptions
):
TextSearchResult
[]
{
let
previousEndLine
=
-
1
;
const
groupedMatches
:
FindMatch
[][]
=
[];
let
currentMatches
:
FindMatch
[]
=
[];
matches
.
forEach
((
match
)
=>
{
if
(
match
.
range
.
startLineNumber
!==
previousEndLine
)
{
currentMatches
=
[];
groupedMatches
.
push
(
currentMatches
);
}
currentMatches
.
push
(
match
);
previousEndLine
=
match
.
range
.
endLineNumber
;
});
return
groupedMatches
.
map
(
sameLineMatches
=>
{
return
editorMatchToTextSearchResult
(
sameLineMatches
,
model
,
previewOptions
);
});
}
\ No newline at end of file
src/vs/workbench/services/search/node/search.ts
浏览文件 @
36d5e046
...
...
@@ -6,7 +6,7 @@
import
{
Event
}
from
'
vs/base/common/event
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IFileSearchStats
,
IFolderQuery
,
IProgress
,
IRaw
TextQuery
,
ISearchEngineStats
,
ISearchQuery
,
ITextSearchResult
,
ITextSearchStats
,
IRawFileQuery
}
from
'
vs/platform/search/common/search
'
;
import
{
IFileSearchStats
,
IFolderQuery
,
IProgress
,
IRaw
FileQuery
,
IRawTextQuery
,
ISearchEngineStats
,
ISearchQuery
,
ITextSearchResult
,
ITextSearchStats
}
from
'
vs/platform/search/common/search
'
;
import
{
ITelemetryData
}
from
'
vs/platform/telemetry/common/telemetry
'
;
export
interface
ITelemetryEvent
{
...
...
src/vs/workbench/services/search/node/searchService.ts
浏览文件 @
36d5e046
...
...
@@ -18,19 +18,18 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
getNextTickChannel
}
from
'
vs/base/parts/ipc/node/ipc
'
;
import
{
Client
,
IIPCOptions
}
from
'
vs/base/parts/ipc/node/ipc.cp
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
FindMatch
,
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IDebugParams
,
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
FileMatch
,
ICachedSearchStats
,
IFileMatch
,
IFileQuery
,
IFileSearchStats
,
IFolderQuery
,
IProgress
,
ISearchComplete
,
ISearchConfiguration
,
ISearchEngineStats
,
ISearchProgressItem
,
ISearchQuery
,
ISearchResultProvider
,
ISearchService
,
ITextQuery
,
ITextSearchPreviewOptions
,
pathIncludedInQuery
,
QueryType
,
SearchProviderType
,
TextSearchResult
}
from
'
vs/platform/search/common/search
'
;
import
{
FileMatch
,
ICachedSearchStats
,
IFileMatch
,
IFileQuery
,
IFileSearchStats
,
IFolderQuery
,
IProgress
,
ISearchComplete
,
ISearchConfiguration
,
ISearchEngineStats
,
ISearchProgressItem
,
ISearchQuery
,
ISearchResultProvider
,
ISearchService
,
ITextQuery
,
pathIncludedInQuery
,
QueryType
,
SearchProviderType
}
from
'
vs/platform/search/common/search
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IRawSearchService
,
ISerializedFileMatch
,
ISerializedSearchComplete
,
ISerializedSearchProgressItem
,
isSerializedSearchComplete
,
isSerializedSearchSuccess
}
from
'
./search
'
;
import
{
ISearchChannel
,
SearchChannelClient
}
from
'
./searchIpc
'
;
import
{
editorMatchesToTextSearchResults
}
from
'
vs/workbench/services/search/common/searchHelpers
'
;
export
class
SearchService
extends
Disposable
implements
ISearchService
{
public
_serviceBrand
:
any
;
...
...
@@ -378,7 +377,7 @@ export class SearchService extends Disposable implements ISearchService {
scheme
,
error
:
errorType
,
useRipgrep
:
query
.
useRipgrep
,
usePCRE2
:
query
.
usePCRE2
usePCRE2
:
!!
query
.
usePCRE2
});
}
}
...
...
@@ -423,9 +422,7 @@ export class SearchService extends Disposable implements ISearchService {
let
fileMatch
=
new
FileMatch
(
resource
);
localResults
.
set
(
resource
,
fileMatch
);
matches
.
forEach
((
match
)
=>
{
fileMatch
.
matches
.
push
(
editorMatchToTextSearchResult
(
match
,
model
,
query
.
previewOptions
));
});
fileMatch
.
matches
=
editorMatchesToTextSearchResults
(
matches
,
model
,
query
.
previewOptions
);
}
else
{
localResults
.
set
(
resource
,
null
);
}
...
...
@@ -584,7 +581,7 @@ export class DiskSearch implements ISearchResultProvider {
private
static
createFileMatch
(
data
:
ISerializedFileMatch
):
FileMatch
{
let
fileMatch
=
new
FileMatch
(
uri
.
file
(
data
.
path
));
if
(
data
.
matches
)
{
fileMatch
.
matches
.
push
(...
data
.
matches
);
// TODO why
fileMatch
.
matches
.
push
(...
data
.
matches
);
}
return
fileMatch
;
}
...
...
@@ -594,9 +591,3 @@ export class DiskSearch implements ISearchResultProvider {
}
}
function
editorMatchToTextSearchResult
(
match
:
FindMatch
,
model
:
ITextModel
,
previewOptions
:
ITextSearchPreviewOptions
):
TextSearchResult
{
return
new
TextSearchResult
(
model
.
getLineContent
(
match
.
range
.
startLineNumber
),
new
Range
(
match
.
range
.
startLineNumber
-
1
,
match
.
range
.
startColumn
-
1
,
match
.
range
.
endLineNumber
-
1
,
match
.
range
.
endColumn
-
1
),
previewOptions
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录