Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
109fab82
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,发现更多精彩内容 >>
提交
109fab82
编写于
11月 22, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#85178 emit the right visible indices
上级
4b6011db
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
10 deletion
+60
-10
src/vs/workbench/browser/parts/views/views.ts
src/vs/workbench/browser/parts/views/views.ts
+13
-10
src/vs/workbench/test/browser/parts/views/views.test.ts
src/vs/workbench/test/browser/parts/views/views.test.ts
+47
-0
未找到文件。
src/vs/workbench/browser/parts/views/views.ts
浏览文件 @
109fab82
...
...
@@ -432,24 +432,27 @@ export class ContributableViewsModel extends Disposable {
const
toRemove
:
{
index
:
number
,
viewDescriptor
:
IViewDescriptor
;
}[]
=
[];
const
toAdd
:
{
index
:
number
,
viewDescriptor
:
IViewDescriptor
,
size
?:
number
,
collapsed
:
boolean
;
}[]
=
[];
const
previous
=
this
.
_viewDescriptors
;
this
.
_viewDescriptors
=
viewDescriptors
.
sort
(
this
.
compareViewDescriptors
.
bind
(
this
));
viewDescriptors
=
viewDescriptors
.
sort
(
this
.
compareViewDescriptors
.
bind
(
this
));
for
(
let
index
=
0
;
index
<
previous
.
length
;
index
++
)
{
const
previousViewDescriptor
=
previous
[
index
];
if
(
this
.
isViewDescriptorVisible
(
previousViewDescriptor
)
&&
this
.
_viewDescriptors
.
every
(
viewDescriptor
=>
viewDescriptor
.
id
!==
previousViewDescriptor
.
id
))
{
toRemove
.
push
({
index
,
viewDescriptor
:
previousViewDescriptor
});
for
(
let
index
=
0
;
index
<
this
.
_viewDescriptors
.
length
;
index
++
)
{
const
currentViewDescriptor
=
this
.
_viewDescriptors
[
index
];
if
(
this
.
isViewDescriptorVisible
(
currentViewDescriptor
)
&&
viewDescriptors
.
every
(
viewDescriptor
=>
viewDescriptor
.
id
!==
currentViewDescriptor
.
id
))
{
const
{
visibleIndex
}
=
this
.
find
(
currentViewDescriptor
.
id
);
toRemove
.
push
({
index
:
visibleIndex
,
viewDescriptor
:
currentViewDescriptor
});
}
}
for
(
let
index
=
0
;
index
<
this
.
_viewDescriptors
.
length
;
index
++
)
{
const
viewDescriptor
=
this
.
_viewDescriptors
[
index
];
const
previous
=
this
.
_viewDescriptors
;
this
.
_viewDescriptors
=
viewDescriptors
.
slice
(
0
);
for
(
let
i
=
0
;
i
<
this
.
_viewDescriptors
.
length
;
i
++
)
{
const
viewDescriptor
=
this
.
_viewDescriptors
[
i
];
if
(
this
.
isViewDescriptorVisible
(
viewDescriptor
)
&&
previous
.
every
(
previousViewDescriptor
=>
previousViewDescriptor
.
id
!==
viewDescriptor
.
id
))
{
const
state
=
this
.
viewStates
.
get
(
viewDescriptor
.
id
)
!
;
toAdd
.
push
({
index
,
viewDescriptor
,
size
:
state
.
size
,
collapsed
:
!!
state
.
collapsed
});
const
{
visibleIndex
,
state
}
=
this
.
find
(
viewDescriptor
.
id
)
;
toAdd
.
push
({
index
:
visibleIndex
,
viewDescriptor
,
size
:
state
.
size
,
collapsed
:
!!
state
.
collapsed
});
}
}
if
(
toRemove
.
length
)
{
this
.
_onDidRemove
.
fire
(
toRemove
);
}
...
...
src/vs/workbench/test/browser/parts/views/views.test.ts
浏览文件 @
109fab82
...
...
@@ -296,6 +296,52 @@ suite('ContributableViewsModel', () => {
assert
.
equal
(
seq
.
elements
.
length
,
0
);
});
test
(
'
view states and when contexts multiple views
'
,
async
function
()
{
const
viewStates
=
new
Map
<
string
,
IViewState
>
();
viewStates
.
set
(
'
view1
'
,
{
visibleGlobal
:
false
,
collapsed
:
false
,
visibleWorkspace
:
undefined
});
const
model
=
new
ContributableViewsModel
(
container
,
viewsService
,
viewStates
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
assert
.
equal
(
model
.
visibleViewDescriptors
.
length
,
0
);
assert
.
equal
(
seq
.
elements
.
length
,
0
);
const
view1
:
IViewDescriptor
=
{
id
:
'
view1
'
,
ctorDescriptor
:
null
!
,
name
:
'
Test View 1
'
,
when
:
ContextKeyExpr
.
equals
(
'
showview
'
,
true
)
};
const
view2
:
IViewDescriptor
=
{
id
:
'
view2
'
,
ctorDescriptor
:
null
!
,
name
:
'
Test View 2
'
,
};
const
view3
:
IViewDescriptor
=
{
id
:
'
view3
'
,
ctorDescriptor
:
null
!
,
name
:
'
Test View 3
'
,
when
:
ContextKeyExpr
.
equals
(
'
showview
'
,
true
)
};
ViewsRegistry
.
registerViews
([
view1
,
view2
,
view3
],
container
);
assert
.
deepEqual
(
model
.
visibleViewDescriptors
,
[
view2
],
'
Only view2 should be visible
'
);
assert
.
deepEqual
(
seq
.
elements
,
[
view2
]);
const
key
=
contextKeyService
.
createKey
(
'
showview
'
,
false
);
assert
.
deepEqual
(
model
.
visibleViewDescriptors
,
[
view2
],
'
Only view2 should be visible
'
);
assert
.
deepEqual
(
seq
.
elements
,
[
view2
]);
key
.
set
(
true
);
await
new
Promise
(
c
=>
setTimeout
(
c
,
30
));
assert
.
deepEqual
(
model
.
visibleViewDescriptors
,
[
view2
,
view3
],
'
view3 should be visible
'
);
assert
.
deepEqual
(
seq
.
elements
,
[
view2
,
view3
]);
key
.
set
(
false
);
await
new
Promise
(
c
=>
setTimeout
(
c
,
30
));
assert
.
deepEqual
(
model
.
visibleViewDescriptors
,
[
view2
],
'
Only view2 should be visible
'
);
assert
.
deepEqual
(
seq
.
elements
,
[
view2
]);
});
test
(
'
remove event is not triggered if view was hidden and removed
'
,
async
function
()
{
const
model
=
new
ContributableViewsModel
(
container
,
viewsService
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
...
...
@@ -324,4 +370,5 @@ suite('ContributableViewsModel', () => {
await
new
Promise
(
c
=>
setTimeout
(
c
,
30
));
assert
.
ok
(
!
target
.
called
,
'
remove event should not be called since it is already hidden
'
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录