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 @@
...
@@ -7,7 +7,7 @@
import
'
vs/css!./media/searchviewlet
'
;
import
'
vs/css!./media/searchviewlet
'
;
import
nls
=
require
(
'
vs/nls
'
);
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
{
EditorType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
lifecycle
=
require
(
'
vs/base/common/lifecycle
'
);
import
lifecycle
=
require
(
'
vs/base/common/lifecycle
'
);
...
@@ -64,7 +64,6 @@ export class SearchViewlet extends Viewlet {
...
@@ -64,7 +64,6 @@ export class SearchViewlet extends Viewlet {
private
isDisposed
:
boolean
;
private
isDisposed
:
boolean
;
private
toDispose
:
lifecycle
.
IDisposable
[];
private
toDispose
:
lifecycle
.
IDisposable
[];
private
currentRequest
:
PPromise
<
ISearchComplete
,
ISearchProgressItem
>
;
private
loading
:
boolean
;
private
loading
:
boolean
;
private
queryBuilder
:
QueryBuilder
;
private
queryBuilder
:
QueryBuilder
;
private
viewModel
:
SearchModel
;
private
viewModel
:
SearchModel
;
...
@@ -257,7 +256,7 @@ export class SearchViewlet extends Viewlet {
...
@@ -257,7 +256,7 @@ export class SearchViewlet extends Viewlet {
this
.
updateGlobalPatternExclusions
(
this
.
configurationService
.
getConfiguration
<
ISearchConfiguration
>
());
this
.
updateGlobalPatternExclusions
(
this
.
configurationService
.
getConfiguration
<
ISearchConfiguration
>
());
this
.
registerListeners
(
);
this
.
toUnbind
.
push
(
this
.
viewModel
.
searchResult
.
onChange
((
event
)
=>
this
.
onSearchResultsChanged
(
event
))
);
return
TPromise
.
as
(
null
);
return
TPromise
.
as
(
null
);
}
}
...
@@ -315,26 +314,30 @@ export class SearchViewlet extends Viewlet {
...
@@ -315,26 +314,30 @@ export class SearchViewlet extends Viewlet {
this
.
storageService
.
store
(
SearchViewlet
.
SHOW_REPLACE_STORAGE_KEY
,
this
.
searchAndReplaceWidget
.
isReplaceShown
(),
StorageScope
.
WORKSPACE
);
this
.
storageService
.
store
(
SearchViewlet
.
SHOW_REPLACE_STORAGE_KEY
,
this
.
searchAndReplaceWidget
.
isReplaceShown
(),
StorageScope
.
WORKSPACE
);
}
}
private
registerListeners
():
void
{
private
onSearchResultsChanged
(
event
?:
IChangeEvent
):
TPromise
<
any
>
{
this
.
toUnbind
.
push
(
this
.
viewModel
.
searchResult
.
onChange
((
event
)
=>
{
return
this
.
refreshTree
(
event
).
then
(()
=>
{
this
.
refreshTree
(
event
);
this
.
searchWidget
.
setReplaceAllActionState
(
!
this
.
viewModel
.
searchResult
.
isEmpty
());
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
)
{
if
(
event
.
added
||
event
.
removed
)
{
this
.
tree
.
refresh
(
this
.
viewModel
.
searchResult
);
return
this
.
tree
.
refresh
(
this
.
viewModel
.
searchResult
).
then
(()
=>
{
if
(
event
.
added
)
{
if
(
event
.
added
)
{
event
.
elements
.
forEach
(
element
=>
{
event
.
elements
.
forEach
(
element
=>
{
this
.
autoExpandFileMatch
(
element
,
true
);
this
.
autoExpandFileMatch
(
element
,
true
);
});
});
}
}
});
}
else
{
}
else
{
if
(
event
.
elements
.
length
===
1
)
{
if
(
event
.
elements
.
length
===
1
)
{
this
.
tree
.
refresh
(
event
.
elements
[
0
]);
return
this
.
tree
.
refresh
(
event
.
elements
[
0
]);
}
else
{
}
else
{
this
.
tree
.
refresh
(
event
.
elements
);
return
this
.
tree
.
refresh
(
event
.
elements
);
}
}
}
}
}
}
...
@@ -526,22 +529,14 @@ export class SearchViewlet extends Viewlet {
...
@@ -526,22 +529,14 @@ export class SearchViewlet extends Viewlet {
this
.
viewModel
.
searchResult
.
clear
();
this
.
viewModel
.
searchResult
.
clear
();
this
.
showEmptyStage
();
this
.
showEmptyStage
();
this
.
searchWidget
.
clear
();
this
.
searchWidget
.
clear
();
if
(
this
.
currentRequest
)
{
this
.
viewModel
.
cancelSearch
();
this
.
currentRequest
.
cancel
();
this
.
currentRequest
=
null
;
}
}
}
public
cancelSearch
():
boolean
{
public
cancelSearch
():
boolean
{
if
(
this
.
currentRequest
)
{
if
(
this
.
viewModel
.
cancelSearch
()
)
{
this
.
searchWidget
.
focus
();
this
.
searchWidget
.
focus
();
this
.
currentRequest
.
cancel
();
this
.
currentRequest
=
null
;
return
true
;
return
true
;
}
}
return
false
;
return
false
;
}
}
...
@@ -697,6 +692,8 @@ export class SearchViewlet extends Viewlet {
...
@@ -697,6 +692,8 @@ export class SearchViewlet extends Viewlet {
}
}
private
onQueryTriggered
(
query
:
ISearchQuery
,
excludePattern
:
string
,
includePattern
:
string
):
void
{
private
onQueryTriggered
(
query
:
ISearchQuery
,
excludePattern
:
string
,
includePattern
:
string
):
void
{
this
.
viewModel
.
cancelSearch
();
// Progress total is 100%
// Progress total is 100%
let
progressTotal
=
100
;
let
progressTotal
=
100
;
let
progressRunner
=
this
.
progressService
.
show
(
progressTotal
);
let
progressRunner
=
this
.
progressService
.
show
(
progressTotal
);
...
@@ -733,10 +730,9 @@ export class SearchViewlet extends Viewlet {
...
@@ -733,10 +730,9 @@ export class SearchViewlet extends Viewlet {
progressRunner
.
done
();
progressRunner
.
done
();
}
}
this
.
onSearchResultsChanged
().
then
(()
=>
autoExpand
(
true
));
this
.
viewModel
.
replaceText
=
this
.
searchWidget
.
getReplaceValue
();
this
.
viewModel
.
replaceText
=
this
.
searchWidget
.
getReplaceValue
();
autoExpand
(
true
);
let
hasResults
=
!
this
.
viewModel
.
searchResult
.
isEmpty
();
let
hasResults
=
!
this
.
viewModel
.
searchResult
.
isEmpty
();
this
.
loading
=
false
;
this
.
loading
=
false
;
...
@@ -882,8 +878,7 @@ export class SearchViewlet extends Viewlet {
...
@@ -882,8 +878,7 @@ export class SearchViewlet extends Viewlet {
this
.
searchWidget
.
setReplaceAllActionState
(
false
);
this
.
searchWidget
.
setReplaceAllActionState
(
false
);
this
.
replaceService
.
disposeAllInputs
();
this
.
replaceService
.
disposeAllInputs
();
this
.
currentRequest
=
this
.
viewModel
.
search
(
query
);
this
.
viewModel
.
search
(
query
).
done
(
onComplete
,
onError
,
onProgress
);
this
.
currentRequest
.
done
(
onComplete
,
onError
,
onProgress
);
}
}
private
showEmptyStage
():
void
{
private
showEmptyStage
():
void
{
...
...
src/vs/workbench/parts/search/common/searchModel.ts
浏览文件 @
bf7e10ce
...
@@ -438,7 +438,7 @@ export class SearchModel extends Disposable {
...
@@ -438,7 +438,7 @@ export class SearchModel extends Disposable {
return
this
.
isReplaceActive
()
&&
!!
this
.
replaceText
;
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
.
cancelSearch
();
this
.
searchResult
.
clear
();
this
.
searchResult
.
clear
();
...
@@ -450,21 +450,23 @@ export class SearchModel extends Disposable {
...
@@ -450,21 +450,23 @@ export class SearchModel extends Disposable {
this
.
currentRequest
=
this
.
searchService
.
search
(
this
.
_searchQuery
);
this
.
currentRequest
=
this
.
searchService
.
search
(
this
.
_searchQuery
);
this
.
currentRequest
.
then
(
value
=>
this
.
onSearchCompleted
(
value
),
this
.
currentRequest
.
then
(
value
=>
this
.
onSearchCompleted
(
value
),
e
=>
this
.
onSearchError
(
e
,
silent
),
e
=>
this
.
onSearchError
(
e
),
p
=>
this
.
onSearchProgress
(
p
,
silent
));
p
=>
this
.
onSearchProgress
(
p
));
return
this
.
currentRequest
;
return
this
.
currentRequest
;
}
}
private
onSearchCompleted
(
completed
:
ISearchComplete
):
ISearchComplete
{
private
onSearchCompleted
(
completed
:
ISearchComplete
):
ISearchComplete
{
this
.
timerEvent
.
stop
();
this
.
timerEvent
.
stop
();
this
.
_searchResult
.
add
(
completed
.
results
);
this
.
telemetryService
.
publicLog
(
'
searchResultsShown
'
,
{
count
:
this
.
_searchResult
.
count
(),
fileCount
:
this
.
_searchResult
.
fileCount
()
});
this
.
telemetryService
.
publicLog
(
'
searchResultsShown
'
,
{
count
:
this
.
_searchResult
.
count
(),
fileCount
:
this
.
_searchResult
.
fileCount
()
});
this
.
doneTimer
.
stop
();
this
.
doneTimer
.
stop
();
if
(
completed
)
{
this
.
_searchResult
.
add
(
completed
.
results
,
false
);
}
return
completed
;
return
completed
;
}
}
private
onSearchError
(
e
:
any
,
silent
:
boolean
):
void
{
private
onSearchError
(
e
:
any
):
void
{
if
(
errors
.
isPromiseCanceledError
(
e
))
{
if
(
errors
.
isPromiseCanceledError
(
e
))
{
this
.
onSearchCompleted
(
null
);
this
.
onSearchCompleted
(
null
);
}
else
{
}
else
{
...
@@ -473,18 +475,20 @@ export class SearchModel extends Disposable {
...
@@ -473,18 +475,20 @@ export class SearchModel extends Disposable {
}
}
}
}
private
onSearchProgress
(
p
:
ISearchProgressItem
,
silent
:
boolean
):
void
{
private
onSearchProgress
(
p
:
ISearchProgressItem
):
void
{
if
(
p
.
resource
)
{
if
(
p
.
resource
)
{
this
.
_searchResult
.
add
([
p
],
silent
);
this
.
_searchResult
.
add
([
p
],
true
);
this
.
progressTimer
.
stop
();
this
.
progressTimer
.
stop
();
}
}
}
}
public
cancelSearch
():
void
{
public
cancelSearch
():
boolean
{
if
(
this
.
currentRequest
)
{
if
(
this
.
currentRequest
)
{
this
.
currentRequest
.
cancel
();
this
.
currentRequest
.
cancel
();
this
.
currentRequest
=
null
;
this
.
currentRequest
=
null
;
return
true
;
}
}
return
false
;
}
}
public
dispose
():
void
{
public
dispose
():
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录