Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b5b20c46
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,发现更多精彩内容 >>
提交
b5b20c46
编写于
7月 17, 2018
作者:
R
Rachel Macfarlane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move collapseDeepestExpandedLevel action implementation out of tree
上级
5c21818c
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
28 addition
and
61 deletion
+28
-61
src/vs/base/parts/tree/browser/tree.ts
src/vs/base/parts/tree/browser/tree.ts
+0
-7
src/vs/base/parts/tree/browser/treeImpl.ts
src/vs/base/parts/tree/browser/treeImpl.ts
+0
-4
src/vs/base/parts/tree/browser/treeModel.ts
src/vs/base/parts/tree/browser/treeModel.ts
+0
-32
src/vs/base/parts/tree/test/browser/treeModel.test.ts
src/vs/base/parts/tree/test/browser/treeModel.test.ts
+0
-17
src/vs/workbench/parts/search/browser/searchActions.ts
src/vs/workbench/parts/search/browser/searchActions.ts
+28
-1
未找到文件。
src/vs/base/parts/tree/browser/tree.ts
浏览文件 @
b5b20c46
...
...
@@ -109,13 +109,6 @@ export interface ITree {
*/
collapseAll
(
elements
?:
any
[],
recursive
?:
boolean
):
WinJS
.
Promise
;
/**
* Collapses several elements.
* Collapses all elements at the greatest tree depth that has expanded elements.
* The returned promise returns a boolean for whether the elements were collapsed or not.
*/
collapseDeepestExpandedLevel
():
WinJS
.
Promise
;
/**
* Toggles an element's expansion state.
*/
...
...
src/vs/base/parts/tree/browser/treeImpl.ts
浏览文件 @
b5b20c46
...
...
@@ -184,10 +184,6 @@ export class Tree implements _.ITree {
return
this
.
model
.
collapseAll
(
elements
,
recursive
);
}
public
collapseDeepestExpandedLevel
():
WinJS
.
Promise
{
return
this
.
model
.
collapseDeepestExpandedLevel
();
}
public
toggleExpansion
(
element
:
any
,
recursive
:
boolean
=
false
):
WinJS
.
Promise
{
return
this
.
model
.
toggleExpansion
(
element
,
recursive
);
}
...
...
src/vs/base/parts/tree/browser/treeModel.ts
浏览文件 @
b5b20c46
...
...
@@ -559,17 +559,6 @@ export class Item {
return
result
;
}
public
getChildren
():
Item
[]
{
var
child
=
this
.
firstChild
;
var
results
=
[];
while
(
child
)
{
results
.
push
(
child
);
child
=
child
.
next
;
}
return
results
;
}
private
isAncestorOf
(
item
:
Item
):
boolean
{
while
(
item
)
{
if
(
item
.
id
===
this
.
id
)
{
...
...
@@ -1040,27 +1029,6 @@ export class TreeModel {
return
WinJS
.
Promise
.
join
(
promises
);
}
public
collapseDeepestExpandedLevel
():
WinJS
.
Promise
{
var
levelToCollapse
=
this
.
findDeepestExpandedLevel
(
this
.
input
,
0
);
var
items
=
[
this
.
input
];
for
(
var
i
=
0
;
i
<
levelToCollapse
;
i
++
)
{
items
=
arrays
.
flatten
(
items
.
map
(
node
=>
node
.
getChildren
()));
}
var
promises
=
items
.
map
(
child
=>
this
.
collapse
(
child
,
false
));
return
WinJS
.
Promise
.
join
(
promises
);
}
private
findDeepestExpandedLevel
(
item
:
Item
,
currentLevel
:
number
):
number
{
var
expandedChildren
=
item
.
getChildren
().
filter
(
child
=>
child
.
isExpanded
());
if
(
!
expandedChildren
.
length
)
{
return
currentLevel
;
}
return
Math
.
max
(...
expandedChildren
.
map
(
child
=>
this
.
findDeepestExpandedLevel
(
child
,
currentLevel
+
1
)));
}
public
toggleExpansion
(
element
:
any
,
recursive
:
boolean
=
false
):
WinJS
.
Promise
{
return
this
.
isExpanded
(
element
)
?
this
.
collapse
(
element
,
recursive
)
:
this
.
expand
(
element
);
}
...
...
src/vs/base/parts/tree/test/browser/treeModel.test.ts
浏览文件 @
b5b20c46
...
...
@@ -613,23 +613,6 @@ suite('TreeModel - Expansion', () => {
});
});
test
(
'
collapseDeepestExpandedLevel
'
,
()
=>
{
return
model
.
setInput
(
SAMPLE
.
DEEP2
).
then
(()
=>
{
return
model
.
expand
(
SAMPLE
.
DEEP2
.
children
[
0
]).
then
(()
=>
{
return
model
.
expand
(
SAMPLE
.
DEEP2
.
children
[
0
].
children
[
0
]).
then
(()
=>
{
assert
(
model
.
isExpanded
(
SAMPLE
.
DEEP2
.
children
[
0
]));
assert
(
model
.
isExpanded
(
SAMPLE
.
DEEP2
.
children
[
0
].
children
[
0
]));
return
model
.
collapseDeepestExpandedLevel
().
then
(()
=>
{
assert
(
model
.
isExpanded
(
SAMPLE
.
DEEP2
.
children
[
0
]));
assert
(
!
model
.
isExpanded
(
SAMPLE
.
DEEP2
.
children
[
0
].
children
[
0
]));
});
});
});
});
});
test
(
'
auto expand single child folders
'
,
()
=>
{
return
model
.
setInput
(
SAMPLE
.
DEEP
).
then
(()
=>
{
return
model
.
expand
(
SAMPLE
.
DEEP
.
children
[
0
]).
then
(()
=>
{
...
...
src/vs/workbench/parts/search/browser/searchActions.ts
浏览文件 @
b5b20c46
...
...
@@ -233,7 +233,34 @@ export class CollapseDeepestExpandedLevelAction extends Action {
return
TPromise
.
as
(
null
);
// Global action disabled if user is in edit mode from another action
}
viewer
.
collapseDeepestExpandedLevel
();
/**
* The hierarchy is FolderMatch, FileMatch, Match. If the top level is FileMatches, then there is only
* one level to collapse so collapse everything. If FolderMatch, check if there are visible grandchildren,
* i.e. if Matches are returned by the navigator, and if so, collapse to them, otherwise collapse all levels.
*/
const
navigator
=
viewer
.
getNavigator
();
let
node
=
navigator
.
first
();
let
collapseFileMatchLevel
=
false
;
if
(
node
instanceof
FolderMatch
)
{
while
(
node
=
navigator
.
next
())
{
if
(
node
instanceof
Match
)
{
collapseFileMatchLevel
=
true
;
break
;
}
}
}
if
(
collapseFileMatchLevel
)
{
node
=
navigator
.
first
();
do
{
if
(
node
instanceof
FileMatch
)
{
viewer
.
collapse
(
node
);
}
}
while
(
node
=
navigator
.
next
());
}
else
{
viewer
.
collapseAll
();
}
viewer
.
clearSelection
();
viewer
.
clearFocus
();
viewer
.
domFocus
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录