Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5bec9e37
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,发现更多精彩内容 >>
提交
5bec9e37
编写于
7月 07, 2016
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Auto expand logic for added files #8278
上级
8c684d1b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
50 addition
and
20 deletion
+50
-20
src/vs/workbench/parts/search/browser/searchViewlet.ts
src/vs/workbench/parts/search/browser/searchViewlet.ts
+30
-11
src/vs/workbench/parts/search/common/searchModel.ts
src/vs/workbench/parts/search/common/searchModel.ts
+20
-9
未找到文件。
src/vs/workbench/parts/search/browser/searchViewlet.ts
浏览文件 @
5bec9e37
...
...
@@ -31,7 +31,7 @@ import {IEditorGroupService} from 'vs/workbench/services/group/common/groupServi
import
{
getOutOfWorkspaceEditorResources
}
from
'
vs/workbench/common/editor
'
;
import
{
FileChangeType
,
FileChangesEvent
,
EventType
as
FileEventType
}
from
'
vs/platform/files/common/files
'
;
import
{
Viewlet
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
Match
,
FileMatch
,
SearchModel
,
FileMatchOrMatch
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
Match
,
FileMatch
,
SearchModel
,
FileMatchOrMatch
,
IChangeEvent
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
getExcludes
,
QueryBuilder
}
from
'
vs/workbench/parts/search/common/searchQuery
'
;
import
{
VIEWLET_ID
}
from
'
vs/workbench/parts/search/common/constants
'
;
import
{
MessageType
,
InputBox
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
...
...
@@ -309,12 +309,29 @@ export class SearchViewlet extends Viewlet {
}
private
registerListeners
():
void
{
this
.
toUnbind
.
push
(
this
.
viewModel
.
searchResult
.
onChange
((
e
lem
ent
)
=>
{
this
.
tree
.
refresh
(
elem
ent
);
this
.
toUnbind
.
push
(
this
.
viewModel
.
searchResult
.
onChange
((
e
v
ent
)
=>
{
this
.
refreshTree
(
ev
ent
);
this
.
searchWidget
.
setReplaceAllActionState
(
!
this
.
viewModel
.
searchResult
.
isEmpty
());
}));
}
private
refreshTree
(
event
:
IChangeEvent
):
void
{
if
(
event
.
added
||
event
.
removed
)
{
this
.
tree
.
refresh
(
this
.
viewModel
.
searchResult
);
if
(
event
.
added
)
{
event
.
elements
.
forEach
(
element
=>
{
this
.
autoExpandFileMatch
(
element
,
true
);
});
}
}
else
{
if
(
event
.
elements
.
length
===
1
)
{
this
.
tree
.
refresh
(
event
.
elements
[
0
]);
}
else
{
this
.
tree
.
refresh
(
event
.
elements
);
}
}
}
private
refreshInputs
():
void
{
this
.
viewModel
.
searchResult
.
matches
().
forEach
((
fileMatch
)
=>
{
this
.
replaceService
.
refreshInput
(
fileMatch
,
this
.
viewModel
.
replaceText
);
...
...
@@ -668,6 +685,15 @@ export class SearchViewlet extends Viewlet {
}
}
private
autoExpandFileMatch
(
fileMatch
:
FileMatch
,
alwaysExpandIfOneResult
:
boolean
):
void
{
let
length
=
fileMatch
.
matches
().
length
;
if
(
length
<
10
||
(
alwaysExpandIfOneResult
&&
this
.
viewModel
.
searchResult
.
count
()
===
1
&&
length
<
50
))
{
this
.
tree
.
expand
(
fileMatch
).
done
(
null
,
errors
.
onUnexpectedError
);
}
else
{
this
.
tree
.
collapse
(
fileMatch
).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
private
onQueryTriggered
(
query
:
ISearchQuery
,
excludePattern
:
string
,
includePattern
:
string
):
void
{
// Progress total is 100%
let
progressTotal
=
100
;
...
...
@@ -688,15 +714,8 @@ export class SearchViewlet extends Viewlet {
if
(
handledMatches
[
match
.
id
()])
{
return
;
// if we once handled a result, do not do it again to keep results stable (the user might have expanded/collapsed meanwhile)
}
handledMatches
[
match
.
id
()]
=
true
;
let
length
=
match
.
matches
().
length
;
if
(
length
<
10
||
(
alwaysExpandIfOneResult
&&
matches
.
length
===
1
&&
length
<
50
))
{
this
.
tree
.
expand
(
match
).
done
(
null
,
errors
.
onUnexpectedError
);
}
else
{
this
.
tree
.
collapse
(
match
).
done
(
null
,
errors
.
onUnexpectedError
);
}
this
.
autoExpandFileMatch
(
match
,
alwaysExpandIfOneResult
);
});
};
...
...
src/vs/workbench/parts/search/common/searchModel.ts
浏览文件 @
5bec9e37
...
...
@@ -236,10 +236,16 @@ export class FileMatch extends Disposable {
}
}
export
interface
IChangeEvent
{
elements
:
FileMatch
[];
added
?:
boolean
;
removed
?:
boolean
;
}
export
class
SearchResult
extends
Disposable
{
private
_onChange
=
this
.
_register
(
new
Emitter
<
any
>
());
public
onChange
:
Event
<
any
>
=
this
.
_onChange
.
event
;
private
_onChange
=
this
.
_register
(
new
Emitter
<
IChangeEvent
>
());
public
onChange
:
Event
<
IChangeEvent
>
=
this
.
_onChange
.
event
;
private
_fileMatches
:
SimpleMap
<
URI
,
FileMatch
>
;
private
_unDisposedFileMatches
:
SimpleMap
<
URI
,
FileMatch
>
;
...
...
@@ -263,27 +269,30 @@ export class SearchResult extends Disposable {
}
public
add
(
raw
:
Search
.
IFileMatch
[],
silent
:
boolean
=
false
):
void
{
let
changed
:
FileMatch
[]
=
[];
raw
.
forEach
((
rawFileMatch
)
=>
{
if
(
!
this
.
_fileMatches
.
has
(
rawFileMatch
.
resource
)){
let
fileMatch
=
this
.
instantiationService
.
createInstance
(
FileMatch
,
this
.
_query
,
this
,
rawFileMatch
);
this
.
doAdd
(
fileMatch
);
changed
.
push
(
fileMatch
);
let
disposable
=
fileMatch
.
onChange
(()
=>
this
.
onFileChange
(
fileMatch
));
fileMatch
.
onDispose
(()
=>
disposable
.
dispose
());
}
});
if
(
!
silent
)
{
this
.
_onChange
.
fire
(
this
);
this
.
_onChange
.
fire
(
{
elements
:
changed
,
added
:
true
}
);
}
}
public
clear
():
void
{
let
changed
:
FileMatch
[]
=
this
.
matches
();
this
.
disposeMatches
();
this
.
_onChange
.
fire
(
this
);
this
.
_onChange
.
fire
(
{
elements
:
changed
,
removed
:
true
}
);
}
public
remove
(
match
:
FileMatch
):
void
{
this
.
doRemove
(
match
);
this
.
_onChange
.
fire
(
this
);
this
.
_onChange
.
fire
(
{
elements
:
[
match
],
removed
:
true
}
);
}
public
replace
(
match
:
FileMatch
,
replaceText
:
string
):
TPromise
<
any
>
{
...
...
@@ -336,17 +345,19 @@ export class SearchResult extends Disposable {
}
private
onFileChange
(
fileMatch
:
FileMatch
):
void
{
let
refreshFile
:
boolean
=
true
;
let
added
:
boolean
=
false
;
let
removed
:
boolean
=
false
;
if
(
!
this
.
_fileMatches
.
has
(
fileMatch
.
resource
()))
{
this
.
doAdd
(
fileMatch
);
refreshFile
=
fals
e
;
added
=
tru
e
;
}
if
(
fileMatch
.
count
()
===
0
)
{
this
.
doRemove
(
fileMatch
,
false
);
refreshFile
=
false
;
added
=
false
;
removed
=
true
;
}
if
(
!
this
.
_replacingAll
)
{
this
.
_onChange
.
fire
(
refreshFile
?
fileMatch
:
this
);
this
.
_onChange
.
fire
(
{
elements
:
[
fileMatch
],
added
:
added
,
removed
:
removed
}
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录