Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
56b8c192
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,发现更多精彩内容 >>
提交
56b8c192
编写于
5月 11, 2020
作者:
S
SteVen Batten
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support contextual title via containerTitle
上级
b01489a2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
84 addition
and
8 deletion
+84
-8
src/vs/workbench/api/browser/viewsExtensionPoint.ts
src/vs/workbench/api/browser/viewsExtensionPoint.ts
+1
-0
src/vs/workbench/browser/parts/panel/panelPart.ts
src/vs/workbench/browser/parts/panel/panelPart.ts
+58
-2
src/vs/workbench/browser/parts/views/viewPaneContainer.ts
src/vs/workbench/browser/parts/views/viewPaneContainer.ts
+22
-5
src/vs/workbench/common/views.ts
src/vs/workbench/common/views.ts
+2
-0
src/vs/workbench/services/views/common/viewContainerModel.ts
src/vs/workbench/services/views/common/viewContainerModel.ts
+1
-1
未找到文件。
src/vs/workbench/api/browser/viewsExtensionPoint.ts
浏览文件 @
56b8c192
...
...
@@ -412,6 +412,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
ctorDescriptor
:
new
SyncDescriptor
(
TreeViewPane
),
when
:
ContextKeyExpr
.
deserialize
(
item
.
when
),
containerIcon
:
viewContainer
?.
icon
,
containerTitle
:
viewContainer
?.
name
,
canToggleVisibility
:
true
,
canMoveView
:
true
,
treeView
:
this
.
instantiationService
.
createInstance
(
CustomTreeView
,
item
.
id
,
item
.
name
),
...
...
src/vs/workbench/browser/parts/panel/panelPart.ts
浏览文件 @
56b8c192
...
...
@@ -50,11 +50,17 @@ interface ICachedPanel {
views
?:
{
when
?:
string
}[];
}
interface
IPlaceholderViewContainer
{
id
:
string
;
name
?:
string
;
}
export
class
PanelPart
extends
CompositePart
<
Panel
>
implements
IPanelService
{
static
readonly
activePanelSettingsKey
=
'
workbench.panelpart.activepanelid
'
;
static
readonly
PINNED_PANELS
=
'
workbench.panel.pinnedPanels
'
;
static
readonly
PLACEHOLDER_VIEW_CONTAINERS
=
'
workbench.panel.placeholderPanels
'
;
private
static
readonly
MIN_COMPOSITE_BAR_WIDTH
=
50
;
_serviceBrand
:
undefined
;
...
...
@@ -94,6 +100,8 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private
blockOpeningPanel
=
false
;
private
contentDimension
:
Dimension
|
undefined
;
private
extensionsRegistered
=
false
;
private
panelRegistry
:
PanelRegistry
;
private
dndHandler
:
ICompositeDragAndDrop
;
...
...
@@ -255,9 +263,11 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
private
updateActivity
(
viewContainer
:
ViewContainer
,
viewContainerModel
:
IViewContainerModel
):
void
{
const
cachedTitle
=
this
.
getPlaceholderViewContainers
().
filter
(
panel
=>
panel
.
id
===
viewContainer
.
id
)[
0
]?.
name
;
const
activity
:
IActivity
=
{
id
:
viewContainer
.
id
,
name
:
viewContainerModel
.
t
itle
,
name
:
this
.
extensionsRegistered
||
cachedTitle
===
undefined
?
viewContainerModel
.
title
:
cachedT
itle
,
keybindingId
:
viewContainer
.
focusCommand
?.
id
};
...
...
@@ -268,7 +278,10 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
pinnedAction
.
setActivity
(
activity
);
}
this
.
saveCachedPanels
();
// only update our cached panel info after extensions are done registering
if
(
this
.
extensionsRegistered
)
{
this
.
saveCachedPanels
();
}
}
private
onDidChangeActiveViews
(
viewContainer
:
ViewContainer
,
viewContainerModel
:
IViewContainerModel
):
void
{
...
...
@@ -313,6 +326,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
private
onDidRegisterExtensions
():
void
{
this
.
extensionsRegistered
=
true
;
this
.
removeNotExistingComposites
();
this
.
saveCachedPanels
();
...
...
@@ -670,6 +684,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private
saveCachedPanels
():
void
{
const
state
:
ICachedPanel
[]
=
[];
const
placeholders
:
IPlaceholderViewContainer
[]
=
[];
const
compositeItems
=
this
.
compositeBar
.
getCompositeBarItems
();
for
(
const
compositeItem
of
compositeItems
)
{
...
...
@@ -677,10 +692,12 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
if
(
viewContainer
)
{
const
viewContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
state
.
push
({
id
:
compositeItem
.
id
,
name
:
viewContainerModel
.
title
,
pinned
:
compositeItem
.
pinned
,
order
:
compositeItem
.
order
,
visible
:
compositeItem
.
visible
});
placeholders
.
push
({
id
:
compositeItem
.
id
,
name
:
this
.
getCompositeActions
(
compositeItem
.
id
).
activityAction
.
label
});
}
}
this
.
cachedPanelsValue
=
JSON
.
stringify
(
state
);
this
.
setPlaceholderViewContainers
(
placeholders
);
}
private
getCachedPanels
():
ICachedPanel
[]
{
...
...
@@ -694,6 +711,13 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
return
serialized
;
});
for
(
const
placeholderViewContainer
of
this
.
getPlaceholderViewContainers
())
{
const
cachedViewContainer
=
cachedPanels
.
filter
(
cached
=>
cached
.
id
===
placeholderViewContainer
.
id
)[
0
];
if
(
cachedViewContainer
)
{
cachedViewContainer
.
name
=
placeholderViewContainer
.
name
;
}
}
return
cachedPanels
;
}
...
...
@@ -721,6 +745,38 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
this
.
storageService
.
store
(
PanelPart
.
PINNED_PANELS
,
value
,
StorageScope
.
GLOBAL
);
}
private
getPlaceholderViewContainers
():
IPlaceholderViewContainer
[]
{
return
JSON
.
parse
(
this
.
placeholderViewContainersValue
);
}
private
setPlaceholderViewContainers
(
placeholderViewContainers
:
IPlaceholderViewContainer
[]):
void
{
this
.
placeholderViewContainersValue
=
JSON
.
stringify
(
placeholderViewContainers
);
}
private
_placeholderViewContainersValue
:
string
|
undefined
;
private
get
placeholderViewContainersValue
():
string
{
if
(
!
this
.
_placeholderViewContainersValue
)
{
this
.
_placeholderViewContainersValue
=
this
.
getStoredPlaceholderViewContainersValue
();
}
return
this
.
_placeholderViewContainersValue
;
}
private
set
placeholderViewContainersValue
(
placeholderViewContainesValue
:
string
)
{
if
(
this
.
placeholderViewContainersValue
!==
placeholderViewContainesValue
)
{
this
.
_placeholderViewContainersValue
=
placeholderViewContainesValue
;
this
.
setStoredPlaceholderViewContainersValue
(
placeholderViewContainesValue
);
}
}
private
getStoredPlaceholderViewContainersValue
():
string
{
return
this
.
storageService
.
get
(
PanelPart
.
PLACEHOLDER_VIEW_CONTAINERS
,
StorageScope
.
WORKSPACE
,
'
[]
'
);
}
private
setStoredPlaceholderViewContainersValue
(
value
:
string
):
void
{
this
.
storageService
.
store
(
PanelPart
.
PLACEHOLDER_VIEW_CONTAINERS
,
value
,
StorageScope
.
WORKSPACE
);
}
private
getViewContainer
(
panelId
:
string
):
ViewContainer
|
undefined
{
return
this
.
viewDescriptorService
.
getViewContainerById
(
panelId
)
||
undefined
;
}
...
...
src/vs/workbench/browser/parts/views/viewPaneContainer.ts
浏览文件 @
56b8c192
...
...
@@ -290,6 +290,10 @@ export abstract class ViewPane extends Pane implements IView {
this
.
_register
(
this
.
toolbar
);
this
.
setActions
();
this
.
_register
(
this
.
viewDescriptorService
.
getViewContainerModel
(
this
.
viewDescriptorService
.
getViewContainerByViewId
(
this
.
id
)
!
)
!
.
onDidChangeContainerInfo
(({
title
})
=>
{
this
.
updateTitle
(
this
.
title
);
}));
const
onDidRelevantConfigurationChange
=
Event
.
filter
(
this
.
configurationService
.
onDidChangeConfiguration
,
e
=>
e
.
affectsConfiguration
(
ViewPane
.
AlwaysShowActionsConfig
));
this
.
_register
(
onDidRelevantConfigurationChange
(
this
.
updateActionsVisibility
,
this
));
this
.
updateActionsVisibility
();
...
...
@@ -300,17 +304,30 @@ export abstract class ViewPane extends Pane implements IView {
}
protected
renderHeaderTitle
(
container
:
HTMLElement
,
title
:
string
):
void
{
this
.
titleContainer
=
append
(
container
,
$
(
'
h3.title
'
,
undefined
,
t
itle
));
this
.
titleContainer
=
append
(
container
,
$
(
'
h3.title
'
,
undefined
,
t
his
.
calculateTitle
(
title
)
));
}
protected
updateTitle
(
title
:
string
):
void
{
updateTitle
(
title
:
string
):
void
{
if
(
this
.
titleContainer
)
{
this
.
titleContainer
.
textContent
=
t
itle
;
this
.
titleContainer
.
textContent
=
t
his
.
calculateTitle
(
title
)
;
}
this
.
title
=
title
;
this
.
_onDidChangeTitleArea
.
fire
();
}
private
calculateTitle
(
title
:
string
):
string
{
const
viewContainer
=
this
.
viewDescriptorService
.
getViewContainerByViewId
(
this
.
id
)
!
;
const
model
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
const
viewDescriptor
=
this
.
viewDescriptorService
.
getViewDescriptorById
(
this
.
id
)
!
;
const
isDefault
=
this
.
viewDescriptorService
.
getDefaultContainerById
(
this
.
id
)
===
viewContainer
;
if
(
!
isDefault
&&
viewDescriptor
.
containerTitle
&&
model
.
title
!==
viewDescriptor
.
containerTitle
)
{
return
`
${
viewDescriptor
.
containerTitle
}
:
${
title
}
`
;
}
return
title
;
}
private
scrollableElement
!
:
DomScrollableElement
;
protected
renderBody
(
container
:
HTMLElement
):
void
{
...
...
@@ -510,7 +527,6 @@ export abstract class ViewPane extends Pane implements IView {
export
interface
IViewPaneContainerOptions
extends
IPaneViewOptions
{
mergeViewWithContainerWhenSingleView
:
boolean
;
donotShowContainerTitleWhenMergedWithContainer
?:
boolean
;
}
interface
IViewPaneItem
{
...
...
@@ -904,7 +920,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
if
(
this
.
isViewMergedWithContainer
())
{
const
paneItemTitle
=
this
.
paneItems
[
0
].
pane
.
title
;
if
(
this
.
options
.
donotShowContainerTitleWhenMergedWithContainer
||
containerTitle
===
paneItemTitle
)
{
if
(
containerTitle
===
paneItemTitle
)
{
return
this
.
paneItems
[
0
].
pane
.
title
;
}
return
paneItemTitle
?
`
${
containerTitle
}
:
${
paneItemTitle
}
`
:
containerTitle
;
...
...
@@ -1227,6 +1243,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
this
.
updateTitleArea
();
}
});
const
onDidChangeVisibility
=
pane
.
onDidChangeBodyVisibility
(()
=>
this
.
_onDidChangeViewVisibility
.
fire
(
pane
));
const
onDidChange
=
pane
.
onDidChange
(()
=>
{
if
(
pane
===
this
.
lastFocusedPane
&&
!
pane
.
isExpanded
())
{
...
...
src/vs/workbench/common/views.ts
浏览文件 @
56b8c192
...
...
@@ -211,6 +211,8 @@ export interface IViewDescriptor {
readonly
containerIcon
?:
string
|
URI
;
readonly
containerTitle
?:
string
;
// Applies only to newly created views
readonly
hideByDefault
?:
boolean
;
...
...
src/vs/workbench/services/views/common/viewContainerModel.ts
浏览文件 @
56b8c192
...
...
@@ -342,7 +342,7 @@ export class ViewContainerModel extends Disposable implements IViewContainerMode
private
updateContainerInfo
():
void
{
/* Use default container info if one of the visible view descriptors belongs to the current container by default */
const
useDefaultContainerInfo
=
this
.
container
.
alwaysUseContainerInfo
||
this
.
visibleViewDescriptors
.
length
===
0
||
this
.
visibleViewDescriptors
.
some
(
v
=>
Registry
.
as
<
IViewsRegistry
>
(
ViewExtensions
.
ViewsRegistry
).
getViewContainer
(
v
.
id
)
===
this
.
container
);
const
title
=
useDefaultContainerInfo
?
this
.
container
.
name
:
this
.
visibleViewDescriptors
[
0
]?.
name
||
''
;
const
title
=
useDefaultContainerInfo
?
this
.
container
.
name
:
this
.
visibleViewDescriptors
[
0
]?.
containerTitle
||
this
.
visibleViewDescriptors
[
0
]?.
name
||
''
;
let
titleChanged
:
boolean
=
false
;
if
(
this
.
_title
!==
title
)
{
this
.
_title
=
title
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录