Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cf6dc50e
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,发现更多精彩内容 >>
提交
cf6dc50e
编写于
11月 28, 2019
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #84569
cc @alexr00
上级
9d19915e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
24 deletion
+67
-24
src/vs/base/browser/ui/tree/asyncDataTree.ts
src/vs/base/browser/ui/tree/asyncDataTree.ts
+10
-5
src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts
src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts
+56
-9
src/vs/workbench/browser/parts/views/customView.ts
src/vs/workbench/browser/parts/views/customView.ts
+1
-10
未找到文件。
src/vs/base/browser/ui/tree/asyncDataTree.ts
浏览文件 @
cf6dc50e
...
@@ -452,7 +452,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
...
@@ -452,7 +452,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
const
viewStateContext
=
viewState
&&
{
viewState
,
focus
:
[],
selection
:
[]
}
as
IAsyncDataTreeViewStateContext
<
TInput
,
T
>
;
const
viewStateContext
=
viewState
&&
{
viewState
,
focus
:
[],
selection
:
[]
}
as
IAsyncDataTreeViewStateContext
<
TInput
,
T
>
;
await
this
.
_updateChildren
(
input
,
true
,
viewStateContext
);
await
this
.
_updateChildren
(
input
,
true
,
false
,
viewStateContext
);
if
(
viewStateContext
)
{
if
(
viewStateContext
)
{
this
.
tree
.
setFocus
(
viewStateContext
.
focus
);
this
.
tree
.
setFocus
(
viewStateContext
.
focus
);
...
@@ -464,11 +464,11 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
...
@@ -464,11 +464,11 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
}
}
}
}
async
updateChildren
(
element
:
TInput
|
T
=
this
.
root
.
element
,
recursive
=
true
):
Promise
<
void
>
{
async
updateChildren
(
element
:
TInput
|
T
=
this
.
root
.
element
,
recursive
=
true
,
rerender
=
false
):
Promise
<
void
>
{
await
this
.
_updateChildren
(
element
,
recursive
);
await
this
.
_updateChildren
(
element
,
recursive
,
rerender
);
}
}
private
async
_updateChildren
(
element
:
TInput
|
T
=
this
.
root
.
element
,
recursive
=
true
,
viewStateContext
?:
IAsyncDataTreeViewStateContext
<
TInput
,
T
>
):
Promise
<
void
>
{
private
async
_updateChildren
(
element
:
TInput
|
T
=
this
.
root
.
element
,
recursive
=
true
,
rerender
=
false
,
viewStateContext
?:
IAsyncDataTreeViewStateContext
<
TInput
,
T
>
):
Promise
<
void
>
{
if
(
typeof
this
.
root
.
element
===
'
undefined
'
)
{
if
(
typeof
this
.
root
.
element
===
'
undefined
'
)
{
throw
new
TreeError
(
this
.
user
,
'
Tree input not set
'
);
throw
new
TreeError
(
this
.
user
,
'
Tree input not set
'
);
}
}
...
@@ -478,7 +478,12 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
...
@@ -478,7 +478,12 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
await
Event
.
toPromise
(
this
.
_onDidRender
.
event
);
await
Event
.
toPromise
(
this
.
_onDidRender
.
event
);
}
}
await
this
.
refreshAndRenderNode
(
this
.
getDataNode
(
element
),
recursive
,
viewStateContext
);
const
node
=
this
.
getDataNode
(
element
);
await
this
.
refreshAndRenderNode
(
node
,
recursive
,
viewStateContext
);
if
(
rerender
)
{
this
.
tree
.
rerender
(
node
);
}
}
}
resort
(
element
:
TInput
|
T
=
this
.
root
.
element
,
recursive
=
true
):
void
{
resort
(
element
:
TInput
|
T
=
this
.
root
.
element
,
recursive
=
true
):
void
{
...
...
src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts
浏览文件 @
cf6dc50e
...
@@ -12,19 +12,28 @@ import { timeout } from 'vs/base/common/async';
...
@@ -12,19 +12,28 @@ import { timeout } from 'vs/base/common/async';
interface
Element
{
interface
Element
{
id
:
string
;
id
:
string
;
suffix
?:
string
;
children
?:
Element
[];
children
?:
Element
[];
}
}
function
find
(
elements
:
Element
[]
|
undefined
,
id
:
string
):
Element
{
function
find
(
element
:
Element
,
id
:
string
):
Element
|
undefined
{
while
(
elements
)
{
if
(
element
.
id
===
id
)
{
for
(
const
element
of
elements
)
{
return
element
;
if
(
element
.
id
===
id
)
{
}
return
element
;
}
if
(
!
element
.
children
)
{
return
undefined
;
}
for
(
const
child
of
element
.
children
)
{
const
result
=
find
(
child
,
id
);
if
(
result
)
{
return
result
;
}
}
}
}
throw
new
Error
(
'
element not found
'
)
;
return
undefined
;
}
}
class
Renderer
implements
ITreeRenderer
<
Element
,
void
,
HTMLElement
>
{
class
Renderer
implements
ITreeRenderer
<
Element
,
void
,
HTMLElement
>
{
...
@@ -33,7 +42,7 @@ class Renderer implements ITreeRenderer<Element, void, HTMLElement> {
...
@@ -33,7 +42,7 @@ class Renderer implements ITreeRenderer<Element, void, HTMLElement> {
return
container
;
return
container
;
}
}
renderElement
(
element
:
ITreeNode
<
Element
,
void
>
,
index
:
number
,
templateData
:
HTMLElement
):
void
{
renderElement
(
element
:
ITreeNode
<
Element
,
void
>
,
index
:
number
,
templateData
:
HTMLElement
):
void
{
templateData
.
textContent
=
element
.
element
.
id
;
templateData
.
textContent
=
element
.
element
.
id
+
(
element
.
element
.
suffix
||
''
)
;
}
}
disposeTemplate
(
templateData
:
HTMLElement
):
void
{
disposeTemplate
(
templateData
:
HTMLElement
):
void
{
// noop
// noop
...
@@ -65,7 +74,13 @@ class Model {
...
@@ -65,7 +74,13 @@ class Model {
constructor
(
readonly
root
:
Element
)
{
}
constructor
(
readonly
root
:
Element
)
{
}
get
(
id
:
string
):
Element
{
get
(
id
:
string
):
Element
{
return
find
(
this
.
root
.
children
,
id
);
const
result
=
find
(
this
.
root
,
id
);
if
(
!
result
)
{
throw
new
Error
(
'
element not found
'
);
}
return
result
;
}
}
}
}
...
@@ -389,4 +404,36 @@ suite('AsyncDataTree', function () {
...
@@ -389,4 +404,36 @@ suite('AsyncDataTree', function () {
assert
(
!
hasClass
(
twistie
,
'
collapsible
'
));
assert
(
!
hasClass
(
twistie
,
'
collapsible
'
));
assert
(
!
hasClass
(
twistie
,
'
collapsed
'
));
assert
(
!
hasClass
(
twistie
,
'
collapsed
'
));
});
});
test
(
'
issues #84569, #82629 - rerender
'
,
async
()
=>
{
const
container
=
document
.
createElement
(
'
div
'
);
const
model
=
new
Model
({
id
:
'
root
'
,
children
:
[{
id
:
'
a
'
,
children
:
[{
id
:
'
b
'
,
suffix
:
'
1
'
}]
}]
});
const
tree
=
new
AsyncDataTree
<
Element
,
Element
>
(
'
test
'
,
container
,
new
VirtualDelegate
(),
[
new
Renderer
()],
new
DataSource
(),
{
identityProvider
:
new
IdentityProvider
()
});
tree
.
layout
(
200
);
await
tree
.
setInput
(
model
.
root
);
await
tree
.
expand
(
model
.
get
(
'
a
'
));
assert
.
deepEqual
(
Array
.
from
(
container
.
querySelectorAll
(
'
.monaco-list-row
'
)).
map
(
e
=>
e
.
textContent
),
[
'
a
'
,
'
b1
'
]);
const
a
=
model
.
get
(
'
a
'
);
const
b
=
model
.
get
(
'
b
'
);
a
.
children
?.
splice
(
0
,
1
,
{
id
:
'
b
'
,
suffix
:
'
2
'
});
await
Promise
.
all
([
tree
.
updateChildren
(
a
,
true
,
true
),
tree
.
updateChildren
(
b
,
true
,
true
)
]);
assert
.
deepEqual
(
Array
.
from
(
container
.
querySelectorAll
(
'
.monaco-list-row
'
)).
map
(
e
=>
e
.
textContent
),
[
'
a
'
,
'
b2
'
]);
});
});
});
src/vs/workbench/browser/parts/views/customView.ts
浏览文件 @
cf6dc50e
...
@@ -614,16 +614,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
...
@@ -614,16 +614,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
const
tree
=
this
.
tree
;
const
tree
=
this
.
tree
;
if
(
tree
&&
this
.
visible
)
{
if
(
tree
&&
this
.
visible
)
{
this
.
refreshing
=
true
;
this
.
refreshing
=
true
;
await
Promise
.
all
(
elements
.
map
(
element
=>
tree
.
updateChildren
(
element
,
true
)));
await
Promise
.
all
(
elements
.
map
(
element
=>
tree
.
updateChildren
(
element
,
true
,
true
)));
elements
.
map
(
element
=>
{
try
{
tree
.
rerender
(
element
);
}
catch
{
// noop
}
});
this
.
refreshing
=
false
;
this
.
refreshing
=
false
;
this
.
updateContentAreas
();
this
.
updateContentAreas
();
if
(
this
.
focused
)
{
if
(
this
.
focused
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录