Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bf7e10ce
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,发现更多精彩内容 >>
提交
bf7e10ce
编写于
7月 07, 2016
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #8829
上级
0a91a54c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
38 deletion
+37
-38
src/vs/workbench/parts/search/browser/searchViewlet.ts
src/vs/workbench/parts/search/browser/searchViewlet.ts
+25
-30
src/vs/workbench/parts/search/common/searchModel.ts
src/vs/workbench/parts/search/common/searchModel.ts
+12
-8
未找到文件。
src/vs/workbench/parts/search/browser/searchViewlet.ts
浏览文件 @
bf7e10ce
...
...
@@ -7,7 +7,7 @@
import
'
vs/css!./media/searchviewlet
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
{
TPromise
,
PPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
EditorType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
lifecycle
=
require
(
'
vs/base/common/lifecycle
'
);
...
...
@@ -64,7 +64,6 @@ export class SearchViewlet extends Viewlet {
private
isDisposed
:
boolean
;
private
toDispose
:
lifecycle
.
IDisposable
[];
private
currentRequest
:
PPromise
<
ISearchComplete
,
ISearchProgressItem
>
;
private
loading
:
boolean
;
private
queryBuilder
:
QueryBuilder
;
private
viewModel
:
SearchModel
;
...
...
@@ -257,7 +256,7 @@ export class SearchViewlet extends Viewlet {
this
.
updateGlobalPatternExclusions
(
this
.
configurationService
.
getConfiguration
<
ISearchConfiguration
>
());
this
.
registerListeners
(
);
this
.
toUnbind
.
push
(
this
.
viewModel
.
searchResult
.
onChange
((
event
)
=>
this
.
onSearchResultsChanged
(
event
))
);
return
TPromise
.
as
(
null
);
}
...
...
@@ -315,26 +314,30 @@ export class SearchViewlet extends Viewlet {
this
.
storageService
.
store
(
SearchViewlet
.
SHOW_REPLACE_STORAGE_KEY
,
this
.
searchAndReplaceWidget
.
isReplaceShown
(),
StorageScope
.
WORKSPACE
);
}
private
registerListeners
():
void
{
this
.
toUnbind
.
push
(
this
.
viewModel
.
searchResult
.
onChange
((
event
)
=>
{
this
.
refreshTree
(
event
);
private
onSearchResultsChanged
(
event
?:
IChangeEvent
):
TPromise
<
any
>
{
return
this
.
refreshTree
(
event
).
then
(()
=>
{
this
.
searchWidget
.
setReplaceAllActionState
(
!
this
.
viewModel
.
searchResult
.
isEmpty
());
})
)
;
});
}
private
refreshTree
(
event
:
IChangeEvent
):
void
{
private
refreshTree
(
event
?:
IChangeEvent
):
TPromise
<
any
>
{
if
(
!
event
)
{
return
this
.
tree
.
refresh
();
}
if
(
event
.
added
||
event
.
removed
)
{
this
.
tree
.
refresh
(
this
.
viewModel
.
searchResult
);
if
(
event
.
added
)
{
event
.
elements
.
forEach
(
element
=>
{
this
.
autoExpandFileMatch
(
element
,
true
);
});
}
return
this
.
tree
.
refresh
(
this
.
viewModel
.
searchResult
).
then
(()
=>
{
if
(
event
.
added
)
{
event
.
elements
.
forEach
(
element
=>
{
this
.
autoExpandFileMatch
(
element
,
true
);
});
}
});
}
else
{
if
(
event
.
elements
.
length
===
1
)
{
this
.
tree
.
refresh
(
event
.
elements
[
0
]);
return
this
.
tree
.
refresh
(
event
.
elements
[
0
]);
}
else
{
this
.
tree
.
refresh
(
event
.
elements
);
return
this
.
tree
.
refresh
(
event
.
elements
);
}
}
}
...
...
@@ -526,22 +529,14 @@ export class SearchViewlet extends Viewlet {
this
.
viewModel
.
searchResult
.
clear
();
this
.
showEmptyStage
();
this
.
searchWidget
.
clear
();
if
(
this
.
currentRequest
)
{
this
.
currentRequest
.
cancel
();
this
.
currentRequest
=
null
;
}
this
.
viewModel
.
cancelSearch
();
}
public
cancelSearch
():
boolean
{
if
(
this
.
currentRequest
)
{
if
(
this
.
viewModel
.
cancelSearch
()
)
{
this
.
searchWidget
.
focus
();
this
.
currentRequest
.
cancel
();
this
.
currentRequest
=
null
;
return
true
;
}
return
false
;
}
...
...
@@ -697,6 +692,8 @@ export class SearchViewlet extends Viewlet {
}
private
onQueryTriggered
(
query
:
ISearchQuery
,
excludePattern
:
string
,
includePattern
:
string
):
void
{
this
.
viewModel
.
cancelSearch
();
// Progress total is 100%
let
progressTotal
=
100
;
let
progressRunner
=
this
.
progressService
.
show
(
progressTotal
);
...
...
@@ -733,10 +730,9 @@ export class SearchViewlet extends Viewlet {
progressRunner
.
done
();
}
this
.
onSearchResultsChanged
().
then
(()
=>
autoExpand
(
true
));
this
.
viewModel
.
replaceText
=
this
.
searchWidget
.
getReplaceValue
();
autoExpand
(
true
);
let
hasResults
=
!
this
.
viewModel
.
searchResult
.
isEmpty
();
this
.
loading
=
false
;
...
...
@@ -882,8 +878,7 @@ export class SearchViewlet extends Viewlet {
this
.
searchWidget
.
setReplaceAllActionState
(
false
);
this
.
replaceService
.
disposeAllInputs
();
this
.
currentRequest
=
this
.
viewModel
.
search
(
query
);
this
.
currentRequest
.
done
(
onComplete
,
onError
,
onProgress
);
this
.
viewModel
.
search
(
query
).
done
(
onComplete
,
onError
,
onProgress
);
}
private
showEmptyStage
():
void
{
...
...
src/vs/workbench/parts/search/common/searchModel.ts
浏览文件 @
bf7e10ce
...
...
@@ -438,7 +438,7 @@ export class SearchModel extends Disposable {
return
this
.
isReplaceActive
()
&&
!!
this
.
replaceText
;
}
public
search
(
query
:
ISearchQuery
,
silent
:
boolean
=
true
):
PPromise
<
ISearchComplete
,
ISearchProgressItem
>
{
public
search
(
query
:
ISearchQuery
):
PPromise
<
ISearchComplete
,
ISearchProgressItem
>
{
this
.
cancelSearch
();
this
.
searchResult
.
clear
();
...
...
@@ -450,21 +450,23 @@ export class SearchModel extends Disposable {
this
.
currentRequest
=
this
.
searchService
.
search
(
this
.
_searchQuery
);
this
.
currentRequest
.
then
(
value
=>
this
.
onSearchCompleted
(
value
),
e
=>
this
.
onSearchError
(
e
,
silent
),
p
=>
this
.
onSearchProgress
(
p
,
silent
));
e
=>
this
.
onSearchError
(
e
),
p
=>
this
.
onSearchProgress
(
p
));
return
this
.
currentRequest
;
}
private
onSearchCompleted
(
completed
:
ISearchComplete
):
ISearchComplete
{
this
.
timerEvent
.
stop
();
this
.
_searchResult
.
add
(
completed
.
results
);
this
.
telemetryService
.
publicLog
(
'
searchResultsShown
'
,
{
count
:
this
.
_searchResult
.
count
(),
fileCount
:
this
.
_searchResult
.
fileCount
()
});
this
.
doneTimer
.
stop
();
if
(
completed
)
{
this
.
_searchResult
.
add
(
completed
.
results
,
false
);
}
return
completed
;
}
private
onSearchError
(
e
:
any
,
silent
:
boolean
):
void
{
private
onSearchError
(
e
:
any
):
void
{
if
(
errors
.
isPromiseCanceledError
(
e
))
{
this
.
onSearchCompleted
(
null
);
}
else
{
...
...
@@ -473,18 +475,20 @@ export class SearchModel extends Disposable {
}
}
private
onSearchProgress
(
p
:
ISearchProgressItem
,
silent
:
boolean
):
void
{
private
onSearchProgress
(
p
:
ISearchProgressItem
):
void
{
if
(
p
.
resource
)
{
this
.
_searchResult
.
add
([
p
],
silent
);
this
.
_searchResult
.
add
([
p
],
true
);
this
.
progressTimer
.
stop
();
}
}
public
cancelSearch
():
void
{
public
cancelSearch
():
boolean
{
if
(
this
.
currentRequest
)
{
this
.
currentRequest
.
cancel
();
this
.
currentRequest
=
null
;
return
true
;
}
return
false
;
}
public
dispose
():
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录