Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e12a9d74
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,体验更适合开发者的 AI 搜索 >>
提交
e12a9d74
编写于
1月 14, 2021
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#114144 fix remote explorer icon flickering
上级
d03490f3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
68 addition
and
46 deletion
+68
-46
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
...vs/workbench/browser/parts/activitybar/activitybarPart.ts
+68
-46
未找到文件。
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
浏览文件 @
e12a9d74
...
...
@@ -23,9 +23,9 @@ import { IStorageService, StorageScope, IStorageValueChangeEvent, StorageTarget
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
ToggleCompositePinnedAction
,
ICompositeBarColors
,
ActivityAction
,
ICompositeActivity
}
from
'
vs/workbench/browser/parts/compositeBarActions
'
;
import
{
IViewDescriptorService
,
ViewContainer
,
TEST_VIEW_CONTAINER_ID
,
IViewContainerModel
,
ViewContainerLocation
,
IViewsService
}
from
'
vs/workbench/common/views
'
;
import
{
IViewDescriptorService
,
ViewContainer
,
IViewContainerModel
,
ViewContainerLocation
,
IViewsService
}
from
'
vs/workbench/common/views
'
;
import
{
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
assertIsDefined
}
from
'
vs/base/common/types
'
;
import
{
assertIsDefined
,
isString
}
from
'
vs/base/common/types
'
;
import
{
IActivityBarService
}
from
'
vs/workbench/services/activityBar/browser/activityBarService
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
...
...
@@ -49,6 +49,7 @@ interface IPlaceholderViewContainer {
readonly
name
?:
string
;
readonly
iconUrl
?:
UriComponents
;
readonly
themeIcon
?:
ThemeIcon
;
readonly
isBuiltin
?:
boolean
;
readonly
views
?:
{
when
?:
string
;
}[];
}
...
...
@@ -66,6 +67,7 @@ interface ICachedViewContainer {
readonly
pinned
:
boolean
;
readonly
order
?:
number
;
visible
:
boolean
;
isBuiltin
?:
boolean
;
views
?:
{
when
?:
string
;
}[];
}
...
...
@@ -116,6 +118,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
private
readonly
keyboardNavigationDisposables
=
this
.
_register
(
new
DisposableStore
());
private
readonly
location
=
ViewContainerLocation
.
Sidebar
;
private
hasExtensionsRegistered
:
boolean
=
false
;
constructor
(
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
...
...
@@ -319,7 +322,22 @@ export class ActivitybarPart extends Part implements IActivityBarService {
}
private
onDidRegisterExtensions
():
void
{
this
.
removeNotExistingComposites
();
this
.
hasExtensionsRegistered
=
true
;
// show/hide/remove composites
for
(
const
{
id
}
of
this
.
cachedViewContainers
)
{
const
viewContainer
=
this
.
getViewContainer
(
id
);
if
(
viewContainer
)
{
this
.
showOrHideViewContainer
(
viewContainer
);
}
else
{
if
(
this
.
viewDescriptorService
.
isViewContainerRemovedPermanently
(
id
))
{
this
.
removeComposite
(
id
);
}
else
{
this
.
hideComposite
(
id
);
}
}
}
this
.
saveCachedViewContainers
();
}
...
...
@@ -331,7 +349,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
this
.
compositeBar
.
addComposite
(
viewContainer
);
this
.
compositeBar
.
activateComposite
(
viewContainer
.
id
);
if
(
viewContainer
.
hideIfEmpty
)
{
if
(
this
.
shouldBeHidden
(
viewContainer
)
)
{
const
viewContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
if
(
viewContainerModel
.
activeViewDescriptors
.
length
===
0
)
{
// Update the composite bar by hiding
...
...
@@ -675,32 +693,27 @@ export class ActivitybarPart extends Part implements IActivityBarService {
private
onDidRegisterViewContainers
(
viewContainers
:
ReadonlyArray
<
ViewContainer
>
):
void
{
for
(
const
viewContainer
of
viewContainers
)
{
const
cachedViewContainer
=
this
.
cachedViewContainers
.
filter
(({
id
})
=>
id
===
viewContainer
.
id
)[
0
];
const
visibleViewContainer
=
this
.
viewsService
.
getVisibleViewContainer
(
this
.
location
);
const
isActive
=
visibleViewContainer
?.
id
===
viewContainer
.
id
;
if
(
isActive
||
!
this
.
shouldBeHidden
(
viewContainer
.
id
,
cachedViewContainer
))
{
this
.
compositeBar
.
addComposite
(
viewContainer
);
this
.
compositeBar
.
addComposite
(
viewContainer
);
// Pin it by default if it is new
if
(
!
cachedViewContainer
)
{
this
.
compositeBar
.
pin
(
viewContainer
.
id
);
}
// Pin it by default if it is new
const
cachedViewContainer
=
this
.
cachedViewContainers
.
filter
(({
id
})
=>
id
===
viewContainer
.
id
)[
0
];
if
(
!
cachedViewContainer
)
{
this
.
compositeBar
.
pin
(
viewContainer
.
id
);
}
if
(
isActive
)
{
this
.
compositeBar
.
activateComposite
(
viewContainer
.
id
);
}
// Active
const
visibleViewContainer
=
this
.
viewsService
.
getVisibleViewContainer
(
this
.
location
);
if
(
visibleViewContainer
?.
id
===
viewContainer
.
id
)
{
this
.
compositeBar
.
activateComposite
(
viewContainer
.
id
);
}
}
for
(
const
viewContainer
of
viewContainers
)
{
const
viewContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
this
.
updateActivity
(
viewContainer
,
viewContainerModel
);
this
.
onDidChangeActiveViews
(
viewContainer
,
viewContainerModel
);
this
.
showOrHideViewContainer
(
viewContainer
);
const
disposables
=
new
DisposableStore
();
disposables
.
add
(
viewContainerModel
.
onDidChangeContainerInfo
(()
=>
this
.
updateActivity
(
viewContainer
,
viewContainerModel
)));
disposables
.
add
(
viewContainerModel
.
onDidChangeActiveViewDescriptors
(()
=>
this
.
onDidChangeActiveViews
(
viewContainer
,
viewContainerModel
)));
disposables
.
add
(
viewContainerModel
.
onDidChangeActiveViewDescriptors
(()
=>
this
.
showOrHideViewContainer
(
viewContainer
)));
this
.
viewContainerDisposables
.
set
(
viewContainer
.
id
,
disposables
);
}
...
...
@@ -755,36 +768,43 @@ export class ActivitybarPart extends Part implements IActivityBarService {
return
{
id
,
name
,
cssClass
,
iconUrl
,
keybindingId
};
}
private
onDidChangeActiveViews
(
viewContainer
:
ViewContainer
,
viewContainerModel
:
IViewContainerModel
):
void
{
if
(
viewContainerModel
.
activeViewDescriptors
.
length
)
{
this
.
compositeBar
.
addComposite
(
viewContainer
);
}
else
if
(
viewContainer
.
hideIfEmpty
)
{
private
showOrHideViewContainer
(
viewContainer
:
ViewContainer
):
void
{
if
(
this
.
shouldBeHidden
(
viewContainer
))
{
this
.
hideComposite
(
viewContainer
.
id
);
}
else
{
this
.
compositeBar
.
addComposite
(
viewContainer
);
}
}
private
shouldBeHidden
(
viewContainerId
:
string
,
cachedViewContainer
?:
ICachedViewContainer
):
boolean
{
const
viewContainer
=
this
.
getViewContainer
(
viewContainerId
);
if
(
!
viewContainer
||
!
viewContainer
.
hideIfEmpty
)
{
return
false
;
private
shouldBeHidden
(
viewContainerOrId
:
string
|
ViewContainer
,
cachedViewContainer
?:
ICachedViewContainer
):
boolean
{
const
viewContainer
=
isString
(
viewContainerOrId
)
?
this
.
getViewContainer
(
viewContainerOrId
)
:
viewContainerOrId
;
const
viewContainerId
=
isString
(
viewContainerOrId
)
?
viewContainerOrId
:
viewContainerOrId
.
id
;
if
(
viewContainer
)
{
if
(
viewContainer
.
hideIfEmpty
)
{
if
(
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
).
activeViewDescriptors
.
length
>
0
)
{
return
false
;
}
}
else
{
return
false
;
}
}
return
cachedViewContainer
?.
views
&&
cachedViewContainer
.
views
.
length
?
cachedViewContainer
.
views
.
every
(({
when
})
=>
!!
when
&&
!
this
.
contextKeyService
.
contextMatchesRules
(
ContextKeyExpr
.
deserialize
(
when
)))
:
viewContainerId
===
TEST_VIEW_CONTAINER_ID
/* Hide Test view container for the first time or it had no views registered before */
;
}
// Check Cache
if
(
!
this
.
hasExtensionsRegistered
)
{
cachedViewContainer
=
cachedViewContainer
||
this
.
cachedViewContainers
.
find
(({
id
})
=>
id
===
viewContainerId
);
private
removeNotExistingComposites
():
void
{
const
viewContainers
=
this
.
getViewContainers
();
for
(
const
{
id
}
of
this
.
cachedViewContainers
)
{
if
(
viewContainers
.
every
(
viewContainer
=>
viewContainer
.
id
!==
id
))
{
if
(
this
.
viewDescriptorService
.
isViewContainerRemovedPermanently
(
id
))
{
this
.
removeComposite
(
id
);
}
else
{
this
.
hideComposite
(
id
);
}
// Show builtin ViewContainer if not registered yet
if
(
!
viewContainer
&&
cachedViewContainer
?.
isBuiltin
)
{
return
false
;
}
if
(
cachedViewContainer
?.
views
?.
length
)
{
return
cachedViewContainer
.
views
.
every
(({
when
})
=>
!!
when
&&
!
this
.
contextKeyService
.
contextMatchesRules
(
ContextKeyExpr
.
deserialize
(
when
)));
}
}
return
true
;
}
private
hideComposite
(
compositeId
:
string
):
void
{
...
...
@@ -876,7 +896,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
private
getViewContainer
(
id
:
string
):
ViewContainer
|
undefined
{
const
viewContainer
=
this
.
viewDescriptorService
.
getViewContainerById
(
id
);
return
viewContainer
&&
this
.
viewDescriptorService
.
getViewContainerLocation
(
viewContainer
)
===
this
.
location
?
viewContainer
:
undefined
;
}
...
...
@@ -941,10 +960,11 @@ export class ActivitybarPart extends Part implements IActivityBarService {
views
,
pinned
:
compositeItem
.
pinned
,
order
:
compositeItem
.
order
,
visible
:
compositeItem
.
visible
visible
:
compositeItem
.
visible
,
isBuiltin
:
!
viewContainer
.
extensionId
});
}
else
{
state
.
push
({
id
:
compositeItem
.
id
,
pinned
:
compositeItem
.
pinned
,
order
:
compositeItem
.
order
,
visible
:
false
});
state
.
push
({
id
:
compositeItem
.
id
,
pinned
:
compositeItem
.
pinned
,
order
:
compositeItem
.
order
,
visible
:
false
,
isBuiltin
:
false
});
}
}
...
...
@@ -962,6 +982,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
cachedViewContainer
.
icon
=
placeholderViewContainer
.
themeIcon
?
placeholderViewContainer
.
themeIcon
:
placeholderViewContainer
.
iconUrl
?
URI
.
revive
(
placeholderViewContainer
.
iconUrl
)
:
undefined
;
cachedViewContainer
.
views
=
placeholderViewContainer
.
views
;
cachedViewContainer
.
isBuiltin
=
placeholderViewContainer
.
isBuiltin
;
}
}
}
...
...
@@ -977,11 +998,12 @@ export class ActivitybarPart extends Part implements IActivityBarService {
order
})));
this
.
setPlaceholderViewContainers
(
cachedViewContainers
.
map
(({
id
,
icon
,
name
,
views
})
=>
(
<
IPlaceholderViewContainer
>
{
this
.
setPlaceholderViewContainers
(
cachedViewContainers
.
map
(({
id
,
icon
,
name
,
views
,
isBuiltin
})
=>
(
<
IPlaceholderViewContainer
>
{
id
,
iconUrl
:
URI
.
isUri
(
icon
)
?
icon
:
undefined
,
themeIcon
:
ThemeIcon
.
isThemeIcon
(
icon
)
?
icon
:
undefined
,
name
,
isBuiltin
,
views
})));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录