Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b77192b4
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,发现更多精彩内容 >>
提交
b77192b4
编写于
2月 21, 2020
作者:
J
Jackson Kearl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #91121.
上级
50e742c4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
45 addition
and
31 deletion
+45
-31
src/vs/workbench/contrib/search/browser/searchView.ts
src/vs/workbench/contrib/search/browser/searchView.ts
+6
-2
src/vs/workbench/contrib/search/browser/searchWidget.ts
src/vs/workbench/contrib/search/browser/searchWidget.ts
+14
-18
src/vs/workbench/contrib/search/common/searchModel.ts
src/vs/workbench/contrib/search/common/searchModel.ts
+11
-4
src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts
...vs/workbench/contrib/searchEditor/browser/searchEditor.ts
+8
-7
src/vs/workbench/services/search/common/search.ts
src/vs/workbench/services/search/common/search.ts
+6
-0
未找到文件。
src/vs/workbench/contrib/search/browser/searchView.ts
浏览文件 @
b77192b4
...
...
@@ -34,7 +34,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
TreeResourceNavigator
,
WorkbenchObjectTree
,
getSelectionKeyboardEvent
}
from
'
vs/platform/list/browser/listService
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IProgressService
,
IProgressStep
,
IProgress
}
from
'
vs/platform/progress/common/progress
'
;
import
{
IPatternInfo
,
ISearchComplete
,
ISearchConfiguration
,
ISearchConfigurationProperties
,
ITextQuery
,
VIEW_ID
,
SearchSortOrder
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
IPatternInfo
,
ISearchComplete
,
ISearchConfiguration
,
ISearchConfigurationProperties
,
ITextQuery
,
VIEW_ID
,
SearchSortOrder
,
SearchCompletionExitCode
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
ISearchHistoryService
,
ISearchHistoryValues
}
from
'
vs/workbench/contrib/search/common/searchHistoryService
'
;
import
{
diffInserted
,
diffInsertedOutline
,
diffRemoved
,
diffRemovedOutline
,
editorFindMatchHighlight
,
editorFindMatchHighlightBorder
,
listActiveSelectionForeground
,
foreground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
ICssStyleCollector
,
ITheme
,
IThemeService
,
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
...
...
@@ -1348,7 +1348,7 @@ export class SearchView extends ViewPane {
this
.
inputPatternIncludes
.
onSearchSubmit
();
});
this
.
viewModel
.
cancelSearch
();
this
.
viewModel
.
cancelSearch
(
true
);
this
.
currentSearchQ
=
this
.
currentSearchQ
.
then
(()
=>
this
.
doSearch
(
query
,
excludePatternText
,
includePatternText
,
triggeredOnType
))
...
...
@@ -1393,6 +1393,10 @@ export class SearchView extends ViewPane {
this
.
updateActions
();
const
hasResults
=
!
this
.
viewModel
.
searchResult
.
isEmpty
();
if
(
completed
?.
exit
===
SearchCompletionExitCode
.
NewSearchStarted
)
{
return
;
}
if
(
completed
&&
completed
.
limitHit
)
{
this
.
searchWidget
.
searchInput
.
showMessage
({
content
:
nls
.
localize
(
'
searchMaxResultsWarning
'
,
"
The result set only contains a subset of all matches. Please be more specific in your search to narrow down the results.
"
),
...
...
src/vs/workbench/contrib/search/browser/searchWidget.ts
浏览文件 @
b77192b4
...
...
@@ -154,7 +154,6 @@ export class SearchWidget extends Widget {
private
readonly
_onDidToggleContext
=
new
Emitter
<
void
>
();
readonly
onDidToggleContext
:
Event
<
void
>
=
this
.
_onDidToggleContext
.
event
;
private
temporarilySkipSearchOnChange
=
false
;
private
showContextCheckbox
!
:
Checkbox
;
private
contextLinesInput
!
:
InputBox
;
...
...
@@ -488,12 +487,10 @@ export class SearchWidget extends Widget {
this
.
setReplaceAllActionState
(
false
);
if
(
this
.
searchConfiguration
.
searchOnType
)
{
if
(
!
this
.
temporarilySkipSearchOnChange
)
{
this
.
_onSearchCancel
.
fire
({
focus
:
false
});
if
(
this
.
searchInput
.
getRegex
())
{
try
{
const
regex
=
new
RegExp
(
this
.
searchInput
.
getValue
(),
'
ug
'
);
const
matchienessHeuristic
=
`
if
(
this
.
searchInput
.
getRegex
())
{
try
{
const
regex
=
new
RegExp
(
this
.
searchInput
.
getValue
(),
'
ug
'
);
const
matchienessHeuristic
=
`
~!@#$%^&*()_+
\`
1234567890-=
qwertyuiop[]\\
...
...
@@ -503,18 +500,17 @@ export class SearchWidget extends Widget {
zxcvbnm,./
ZXCVBNM<>? `
.
match
(
regex
)?.
length
??
0
;
const
delayMultiplier
=
matchienessHeuristic
<
50
?
1
:
matchienessHeuristic
<
100
?
5
:
// expressions like `.` or `\w`
10
;
// only things matching empty string
this
.
submitSearch
(
true
,
this
.
searchConfiguration
.
searchOnTypeDebouncePeriod
*
delayMultiplier
);
}
catch
{
// pass
}
}
else
{
this
.
submitSearch
(
true
,
this
.
searchConfiguration
.
searchOnTypeDebouncePeriod
);
const
delayMultiplier
=
matchienessHeuristic
<
50
?
1
:
matchienessHeuristic
<
100
?
5
:
// expressions like `.` or `\w`
10
;
// only things matching empty string
this
.
submitSearch
(
true
,
this
.
searchConfiguration
.
searchOnTypeDebouncePeriod
*
delayMultiplier
);
}
catch
{
// pass
}
}
else
{
this
.
submitSearch
(
true
,
this
.
searchConfiguration
.
searchOnTypeDebouncePeriod
);
}
}
}
...
...
src/vs/workbench/contrib/search/common/searchModel.ts
浏览文件 @
b77192b4
...
...
@@ -20,7 +20,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import
{
createDecorator
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IProgress
,
IProgressStep
}
from
'
vs/platform/progress/common/progress
'
;
import
{
ReplacePattern
}
from
'
vs/workbench/services/search/common/replace
'
;
import
{
IFileMatch
,
IPatternInfo
,
ISearchComplete
,
ISearchProgressItem
,
ISearchConfigurationProperties
,
ISearchService
,
ITextQuery
,
ITextSearchPreviewOptions
,
ITextSearchMatch
,
ITextSearchStats
,
resultIsMatch
,
ISearchRange
,
OneLineRange
,
ITextSearchContext
,
ITextSearchResult
,
SearchSortOrder
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
IFileMatch
,
IPatternInfo
,
ISearchComplete
,
ISearchProgressItem
,
ISearchConfigurationProperties
,
ISearchService
,
ITextQuery
,
ITextSearchPreviewOptions
,
ITextSearchMatch
,
ITextSearchStats
,
resultIsMatch
,
ISearchRange
,
OneLineRange
,
ITextSearchContext
,
ITextSearchResult
,
SearchSortOrder
,
SearchCompletionExitCode
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
overviewRulerFindMatchForeground
,
minimapFindMatch
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
themeColorFromId
}
from
'
vs/platform/theme/common/themeService
'
;
...
...
@@ -968,6 +968,7 @@ export class SearchModel extends Disposable {
readonly
onReplaceTermChanged
:
Event
<
void
>
=
this
.
_onReplaceTermChanged
.
event
;
private
currentCancelTokenSource
:
CancellationTokenSource
|
null
=
null
;
private
searchCancelledForNewSearch
:
boolean
=
false
;
constructor
(
@
ISearchService
private
readonly
searchService
:
ISearchService
,
...
...
@@ -1016,7 +1017,7 @@ export class SearchModel extends Disposable {
}
search
(
query
:
ITextQuery
,
onProgress
?:
(
result
:
ISearchProgressItem
)
=>
void
):
Promise
<
ISearchComplete
>
{
this
.
cancelSearch
();
this
.
cancelSearch
(
true
);
this
.
_searchQuery
=
query
;
...
...
@@ -1114,7 +1115,12 @@ export class SearchModel extends Disposable {
private
onSearchError
(
e
:
any
,
duration
:
number
):
void
{
if
(
errors
.
isPromiseCanceledError
(
e
))
{
this
.
onSearchCompleted
(
null
,
duration
);
this
.
onSearchCompleted
(
this
.
searchCancelledForNewSearch
?
{
exit
:
SearchCompletionExitCode
.
NewSearchStarted
,
results
:
[]
}
:
null
,
duration
);
this
.
searchCancelledForNewSearch
=
false
;
}
}
...
...
@@ -1133,8 +1139,9 @@ export class SearchModel extends Disposable {
return
this
.
configurationService
.
getValue
<
ISearchConfigurationProperties
>
(
'
search
'
);
}
cancelSearch
():
boolean
{
cancelSearch
(
cancelledForNewSearch
=
false
):
boolean
{
if
(
this
.
currentCancelTokenSource
)
{
this
.
searchCancelledForNewSearch
=
cancelledForNewSearch
;
this
.
currentCancelTokenSource
.
cancel
();
return
true
;
}
...
...
src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts
浏览文件 @
b77192b4
...
...
@@ -77,6 +77,7 @@ export class SearchEditor extends BaseTextEditor {
private
searchHistoryDelayer
:
Delayer
<
void
>
;
private
messageDisposables
:
IDisposable
[]
=
[];
private
container
:
HTMLElement
;
private
searchModel
:
SearchModel
;
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
...
...
@@ -107,6 +108,8 @@ export class SearchEditor extends BaseTextEditor {
this
.
inputFocusContextKey
=
InputBoxFocusedKey
.
bindTo
(
scopedContextKeyService
);
this
.
searchOperation
=
this
.
_register
(
new
LongRunningOperation
(
progressService
));
this
.
searchHistoryDelayer
=
new
Delayer
<
void
>
(
2000
);
this
.
searchModel
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
SearchModel
));
}
createEditor
(
parent
:
HTMLElement
)
{
...
...
@@ -326,6 +329,8 @@ export class SearchEditor extends BaseTextEditor {
}
private
async
doRunSearch
()
{
this
.
searchModel
.
cancelSearch
(
true
);
const
startInput
=
this
.
getInput
();
this
.
searchHistoryDelayer
.
trigger
(()
=>
{
...
...
@@ -372,30 +377,26 @@ export class SearchEditor extends BaseTextEditor {
catch
(
err
)
{
return
;
}
const
searchModel
=
this
.
instantiationService
.
createInstance
(
SearchModel
);
this
.
searchOperation
.
start
(
500
);
await
searchModel
.
search
(
query
).
finally
(()
=>
this
.
searchOperation
.
stop
());
await
this
.
searchModel
.
search
(
query
).
finally
(()
=>
this
.
searchOperation
.
stop
());
const
input
=
this
.
getInput
();
if
(
!
input
||
input
!==
startInput
||
JSON
.
stringify
(
config
)
!==
JSON
.
stringify
(
this
.
readConfigFromWidget
()))
{
searchModel
.
dispose
();
return
;
}
const
controller
=
ReferencesController
.
get
(
this
.
searchResultEditor
);
controller
.
closeWidget
(
false
);
const
labelFormatter
=
(
uri
:
URI
):
string
=>
this
.
labelService
.
getUriLabel
(
uri
,
{
relative
:
true
});
const
results
=
serializeSearchResultForEditor
(
searchModel
.
searchResult
,
config
.
includes
,
config
.
excludes
,
config
.
contextLines
,
labelFormatter
,
false
);
const
results
=
serializeSearchResultForEditor
(
this
.
searchModel
.
searchResult
,
config
.
includes
,
config
.
excludes
,
config
.
contextLines
,
labelFormatter
,
false
);
const
{
header
,
body
}
=
await
input
.
getModels
();
this
.
modelService
.
updateModel
(
body
,
results
.
text
);
header
.
setValue
(
serializeSearchConfiguration
(
config
));
input
.
setDirty
(
input
.
resource
.
scheme
!==
'
search-editor
'
);
input
.
setMatchRanges
(
results
.
matchRanges
);
searchModel
.
dispose
();
}
layout
(
dimension
:
DOM
.
Dimension
)
{
...
...
src/vs/workbench/services/search/common/search.ts
浏览文件 @
b77192b4
...
...
@@ -198,6 +198,12 @@ export interface ISearchCompleteStats {
export
interface
ISearchComplete
extends
ISearchCompleteStats
{
results
:
IFileMatch
[];
exit
?:
SearchCompletionExitCode
}
export
const
enum
SearchCompletionExitCode
{
Normal
,
NewSearchStarted
}
export
interface
ITextSearchStats
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录