Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
379e077c
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,发现更多精彩内容 >>
提交
379e077c
编写于
9月 21, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tree: collapse all
上级
00d5c289
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
57 addition
and
19 deletion
+57
-19
src/vs/base/browser/ui/tree/tree.ts
src/vs/base/browser/ui/tree/tree.ts
+3
-0
src/vs/base/browser/ui/tree/treeModel.ts
src/vs/base/browser/ui/tree/treeModel.ts
+23
-7
test/tree/public/index.html
test/tree/public/index.html
+31
-12
未找到文件。
src/vs/base/browser/ui/tree/tree.ts
浏览文件 @
379e077c
...
...
@@ -170,6 +170,9 @@ export class Tree<T> implements IDisposable {
onKeyDown
.
filter
(
e
=>
e
.
keyCode
===
KeyCode
.
LeftArrow
).
on
(
this
.
onLeftArrow
,
this
,
this
.
disposables
);
onKeyDown
.
filter
(
e
=>
e
.
keyCode
===
KeyCode
.
RightArrow
).
on
(
this
.
onRightArrow
,
this
,
this
.
disposables
);
onKeyDown
.
filter
(
e
=>
e
.
keyCode
===
KeyCode
.
Space
).
on
(
this
.
onSpace
,
this
,
this
.
disposables
);
// TODO@joao cleanup
onKeyDown
.
filter
(
e
=>
e
.
keyCode
===
KeyCode
.
KEY_A
).
on
(()
=>
this
.
model
.
setCollapsedAll
(
true
),
null
,
this
.
disposables
);
}
splice
(
location
:
number
[],
deleteCount
:
number
,
toInsert
:
ISequence
<
ITreeElement
<
T
>>
=
Iterator
.
empty
()):
Iterator
<
ITreeElement
<
T
>>
{
...
...
src/vs/base/browser/ui/tree/treeModel.ts
浏览文件 @
379e077c
...
...
@@ -166,16 +166,16 @@ export class TreeModel<T> {
}
setCollapsed
(
location
:
number
[],
collapsed
:
boolean
):
boolean
{
return
this
.
_setCollapsed
(
location
,
collapsed
);
const
{
node
,
listIndex
,
visible
}
=
this
.
findNode
(
location
);
return
this
.
_setCollapsed
(
node
,
listIndex
,
visible
,
collapsed
);
}
toggleCollapsed
(
location
:
number
[]):
void
{
this
.
_setCollapsed
(
location
);
}
private
_setCollapsed
(
location
:
number
[],
collapsed
?:
boolean
|
undefined
):
boolean
{
const
{
node
,
listIndex
,
visible
}
=
this
.
findNode
(
location
);
this
.
_setCollapsed
(
node
,
listIndex
,
visible
);
}
private
_setCollapsed
(
node
:
IMutableTreeNode
<
T
>
,
listIndex
:
number
,
visible
:
boolean
,
collapsed
?:
boolean
|
undefined
):
boolean
{
if
(
!
node
.
collapsible
)
{
return
false
;
}
...
...
@@ -195,13 +195,29 @@ export class TreeModel<T> {
const
toInsert
=
updateVisibleCount
(
node
);
this
.
list
.
splice
(
listIndex
+
1
,
previousVisibleCount
-
1
,
toInsert
.
slice
(
1
));
this
.
_onDidChangeCollapseState
.
fire
(
node
);
}
this
.
_onDidChangeCollapseState
.
fire
(
node
);
return
true
;
}
// TODO@joao cleanup
setCollapsedAll
(
collapsed
:
boolean
):
void
{
if
(
collapsed
)
{
const
queue
=
[...
this
.
root
.
children
];
// TODO@joao use a linked list
let
listIndex
=
0
;
while
(
queue
.
length
>
0
)
{
const
node
=
queue
.
shift
();
const
visible
=
listIndex
<
this
.
root
.
children
.
length
;
this
.
_setCollapsed
(
node
,
listIndex
,
visible
,
collapsed
);
queue
.
push
(...
node
.
children
);
listIndex
++
;
}
}
}
isCollapsed
(
location
:
number
[]):
boolean
{
return
this
.
findNode
(
location
).
node
.
collapsed
;
}
...
...
test/tree/public/index.html
浏览文件 @
379e077c
...
...
@@ -44,21 +44,40 @@
const
tree
=
new
Tree
(
container
,
delegate
,
[
renderer
]);
const
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'
GET
'
,
'
/api/ls?path=
'
);
xhr
.
send
();
xhr
.
onreadystatechange
=
function
()
{
if
(
this
.
readyState
==
4
&&
this
.
status
==
200
)
{
const
data
=
JSON
.
parse
(
this
.
responseText
);
function
setModel
(
model
)
{
performance
.
mark
(
'
before splice
'
);
const
start
=
performance
.
now
();
tree
.
splice
([
0
],
0
,
model
);
console
.
log
(
'
splice took
'
,
performance
.
now
()
-
start
);
performance
.
mark
(
'
after splice
'
);
}
performance
.
mark
(
'
before splice
'
);
const
start
=
performance
.
now
();
tree
.
splice
([
0
],
0
,
[
data
])
;
console
.
log
(
'
splice took
'
,
performance
.
now
()
-
start
);
performance
.
mark
(
'
after splice
'
)
;
switch
(
location
.
search
)
{
case
'
?problems
'
:
{
const
files
=
[]
;
for
(
let
i
=
0
;
i
<
10000
;
i
++
)
{
const
errors
=
[]
;
for
(
let
j
=
1
;
j
<=
(
i
%
5
)
+
1
;
j
++
)
{
errors
.
push
({
element
:
`error #
${
j
}
`
});
}
files
.
push
({
element
:
`file #
${
i
}
`
,
children
:
errors
});
}
setModel
(
files
);
break
;
}
};
default
:
const
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'
GET
'
,
'
/api/ls?path=
'
);
xhr
.
send
();
xhr
.
onreadystatechange
=
function
()
{
if
(
this
.
readyState
==
4
&&
this
.
status
==
200
)
{
setModel
([
JSON
.
parse
(
this
.
responseText
)]);
}
};
}
});
</script>
</body>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录