Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3900d3c2
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 搜索 >>
提交
3900d3c2
编写于
7月 04, 2019
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix search cancel/refresh actions, simplify search ui state
Fix #76151
上级
8627d1e3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
28 deletion
+28
-28
src/vs/workbench/contrib/search/browser/searchActions.ts
src/vs/workbench/contrib/search/browser/searchActions.ts
+3
-5
src/vs/workbench/contrib/search/browser/searchView.ts
src/vs/workbench/contrib/search/browser/searchView.ts
+25
-23
未找到文件。
src/vs/workbench/contrib/search/browser/searchActions.ts
浏览文件 @
3900d3c2
...
...
@@ -259,18 +259,16 @@ export class RefreshAction extends Action {
static
readonly
ID
:
string
=
'
search.action.refreshSearchResults
'
;
static
LABEL
:
string
=
nls
.
localize
(
'
RefreshAction.label
'
,
"
Refresh
"
);
private
searchView
:
SearchView
|
undefined
;
constructor
(
id
:
string
,
label
:
string
,
@
IViewletService
private
readonly
viewletService
:
IViewletService
,
@
IPanelService
private
readonly
panelService
:
IPanelService
)
{
super
(
id
,
label
,
'
search-action refresh
'
);
this
.
searchView
=
getSearchView
(
this
.
viewletService
,
this
.
panelService
);
}
get
enabled
():
boolean
{
return
!!
this
.
searchView
&&
this
.
searchView
.
isSearchSubmitted
();
const
searchView
=
getSearchView
(
this
.
viewletService
,
this
.
panelService
);
return
!!
searchView
&&
searchView
.
hasSearchResults
();
}
update
():
void
{
...
...
@@ -386,7 +384,7 @@ export class CancelSearchAction extends Action {
update
():
void
{
const
searchView
=
getSearchView
(
this
.
viewletService
,
this
.
panelService
);
this
.
enabled
=
!!
searchView
&&
searchView
.
isS
earching
();
this
.
enabled
=
!!
searchView
&&
searchView
.
isS
lowSearch
();
}
run
():
Promise
<
void
>
{
...
...
src/vs/workbench/contrib/search/browser/searchView.ts
浏览文件 @
3900d3c2
...
...
@@ -64,6 +64,12 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
const
$
=
dom
.
$
;
enum
SearchUIState
{
Idle
,
Searching
,
SlowSearch
}
export
class
SearchView
extends
ViewletPanel
{
private
static
readonly
MAX_TEXT_RESULTS
=
10000
;
...
...
@@ -92,8 +98,7 @@ export class SearchView extends ViewletPanel {
private
matchFocused
:
IContextKey
<
boolean
>
;
private
hasSearchResultsKey
:
IContextKey
<
boolean
>
;
private
searchSubmitted
:
boolean
;
private
searching
:
boolean
;
private
state
:
SearchUIState
;
private
actions
:
Array
<
CollapseDeepestExpandedLevelAction
|
ClearSearchResultsAction
>
=
[];
private
cancelAction
:
CancelSearchAction
;
...
...
@@ -335,9 +340,11 @@ export class SearchView extends ViewletPanel {
protected
updateActions
():
void
{
for
(
const
action
of
this
.
actions
)
{
action
.
update
();
this
.
refreshAction
.
update
();
this
.
cancelAction
.
update
();
}
this
.
refreshAction
.
update
();
this
.
cancelAction
.
update
();
super
.
updateActions
();
}
...
...
@@ -907,12 +914,8 @@ export class SearchView extends ViewletPanel {
return
this
.
tree
;
}
isSearchSubmitted
():
boolean
{
return
this
.
searchSubmitted
;
}
isSearching
():
boolean
{
return
this
.
searching
;
isSlowSearch
():
boolean
{
return
this
.
state
===
SearchUIState
.
SlowSearch
;
}
allSearchFieldsClear
():
boolean
{
...
...
@@ -1256,16 +1259,17 @@ export class SearchView extends ViewletPanel {
});
this
.
searchWidget
.
searchInput
.
clearMessage
();
this
.
searching
=
true
;
setTimeout
(()
=>
{
if
(
this
.
searching
)
{
this
.
updateActions
();
}
},
2000
);
this
.
state
=
SearchUIState
.
Searching
;
this
.
showEmptyStage
();
const
slowTimer
=
setTimeout
(()
=>
{
this
.
state
=
SearchUIState
.
SlowSearch
;
this
.
updateActions
();
},
2000
);
const
onComplete
=
(
completed
?:
ISearchComplete
)
=>
{
this
.
searching
=
false
;
clearTimeout
(
slowTimer
);
this
.
state
=
SearchUIState
.
Idle
;
// Complete up to 100% as needed
progressComplete
();
...
...
@@ -1283,7 +1287,6 @@ export class SearchView extends ViewletPanel {
this
.
viewModel
.
replaceString
=
this
.
searchWidget
.
getReplaceValue
();
this
.
searchSubmitted
=
true
;
this
.
updateActions
();
const
hasResults
=
!
this
.
viewModel
.
searchResult
.
isEmpty
();
...
...
@@ -1358,10 +1361,11 @@ export class SearchView extends ViewletPanel {
};
const
onError
=
(
e
:
any
)
=>
{
clearTimeout
(
slowTimer
);
this
.
state
=
SearchUIState
.
Idle
;
if
(
errors
.
isPromiseCanceledError
(
e
))
{
return
onComplete
(
undefined
);
}
else
{
this
.
searching
=
false
;
this
.
updateActions
();
progressComplete
();
this
.
searchWidget
.
searchInput
.
showMessage
({
content
:
e
.
message
,
type
:
MessageType
.
ERROR
});
...
...
@@ -1381,7 +1385,7 @@ export class SearchView extends ViewletPanel {
// Handle UI updates in an interval to show frequent progress and results
const
uiRefreshHandle
:
any
=
setInterval
(()
=>
{
if
(
!
this
.
searching
)
{
if
(
this
.
state
===
SearchUIState
.
Idle
)
{
window
.
clearInterval
(
uiRefreshHandle
);
return
;
}
...
...
@@ -1515,9 +1519,7 @@ export class SearchView extends ViewletPanel {
}
private
showEmptyStage
():
void
{
// disable 'result'-actions
this
.
searchSubmitted
=
false
;
this
.
updateActions
();
// clean up ui
...
...
@@ -1617,7 +1619,7 @@ export class SearchView extends ViewletPanel {
getActions
():
IAction
[]
{
return
[
this
.
s
earching
?
this
.
s
tate
===
SearchUIState
.
SlowSearch
?
this
.
cancelAction
:
this
.
refreshAction
,
...
this
.
actions
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录