Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8bb358f2
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 搜索 >>
未验证
提交
8bb358f2
编写于
11月 13, 2019
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip: icon label supports multiple labels
上级
65b57bcd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
115 addition
and
26 deletion
+115
-26
src/vs/base/browser/ui/iconLabel/iconLabel.ts
src/vs/base/browser/ui/iconLabel/iconLabel.ts
+91
-13
src/vs/base/browser/ui/iconLabel/iconlabel.css
src/vs/base/browser/ui/iconLabel/iconlabel.css
+12
-7
src/vs/workbench/browser/labels.ts
src/vs/workbench/browser/labels.ts
+4
-2
src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
...s/workbench/contrib/files/browser/views/explorerViewer.ts
+7
-4
src/vs/workbench/contrib/scm/browser/media/scmViewlet.css
src/vs/workbench/contrib/scm/browser/media/scmViewlet.css
+1
-0
未找到文件。
src/vs/base/browser/ui/iconLabel/iconLabel.ts
浏览文件 @
8bb358f2
...
...
@@ -24,6 +24,7 @@ export interface IIconLabelValueOptions {
matches
?:
IMatch
[];
labelEscapeNewLines
?:
boolean
;
descriptionMatches
?:
IMatch
[];
readonly
separator
?:
string
;
}
class
FastLabelNode
{
...
...
@@ -86,9 +87,10 @@ class FastLabelNode {
}
export
class
IconLabel
extends
Disposable
{
private
domNode
:
FastLabelNode
;
private
labelD
escriptionContainer
:
FastLabelNode
;
private
labelNode
:
FastLabelNode
|
HighlightedLabel
;
private
d
escriptionContainer
:
FastLabelNode
;
private
nameNode
:
Label
|
LabelWithHighlights
;
private
descriptionNode
:
FastLabelNode
|
HighlightedLabel
|
undefined
;
private
descriptionNodeFactory
:
()
=>
FastLabelNode
|
HighlightedLabel
;
...
...
@@ -97,18 +99,21 @@ export class IconLabel extends Disposable {
this
.
domNode
=
this
.
_register
(
new
FastLabelNode
(
dom
.
append
(
container
,
dom
.
$
(
'
.monaco-icon-label
'
))));
this
.
labelDescriptionContainer
=
this
.
_register
(
new
FastLabelNode
(
dom
.
append
(
this
.
domNode
.
element
,
dom
.
$
(
'
.monaco-icon-label-description-container
'
))));
const
labelContainer
=
dom
.
append
(
this
.
domNode
.
element
,
dom
.
$
(
'
.monaco-icon-label-container
'
));
const
nameContainer
=
dom
.
append
(
labelContainer
,
dom
.
$
(
'
span.monaco-icon-name-container
'
));
this
.
descriptionContainer
=
this
.
_register
(
new
FastLabelNode
(
dom
.
append
(
labelContainer
,
dom
.
$
(
'
span.monaco-icon-description-container
'
))));
if
(
options
?.
supportHighlights
)
{
this
.
labelNode
=
new
HighlightedLabel
(
dom
.
append
(
this
.
labelDescriptionContainer
.
element
,
dom
.
$
(
'
a.label-name
'
))
,
!!
options
.
supportCodicons
);
this
.
nameNode
=
new
LabelWithHighlights
(
nameContainer
,
!!
options
.
supportCodicons
);
}
else
{
this
.
labelNode
=
this
.
_register
(
new
FastLabelNode
(
dom
.
append
(
this
.
labelDescriptionContainer
.
element
,
dom
.
$
(
'
a.label-name
'
)))
);
this
.
nameNode
=
new
Label
(
nameContainer
);
}
if
(
options
?.
supportDescriptionHighlights
)
{
this
.
descriptionNodeFactory
=
()
=>
new
HighlightedLabel
(
dom
.
append
(
this
.
labelD
escriptionContainer
.
element
,
dom
.
$
(
'
span.label-description
'
)),
!!
options
.
supportCodicons
);
this
.
descriptionNodeFactory
=
()
=>
new
HighlightedLabel
(
dom
.
append
(
this
.
d
escriptionContainer
.
element
,
dom
.
$
(
'
span.label-description
'
)),
!!
options
.
supportCodicons
);
}
else
{
this
.
descriptionNodeFactory
=
()
=>
this
.
_register
(
new
FastLabelNode
(
dom
.
append
(
this
.
labelD
escriptionContainer
.
element
,
dom
.
$
(
'
span.label-description
'
))));
this
.
descriptionNodeFactory
=
()
=>
this
.
_register
(
new
FastLabelNode
(
dom
.
append
(
this
.
d
escriptionContainer
.
element
,
dom
.
$
(
'
span.label-description
'
))));
}
}
...
...
@@ -116,7 +121,7 @@ export class IconLabel extends Disposable {
return
this
.
domNode
.
element
;
}
setLabel
(
label
:
string
,
description
?:
string
,
options
?:
IIconLabelValueOptions
):
void
{
setLabel
(
label
:
string
|
string
[]
,
description
?:
string
,
options
?:
IIconLabelValueOptions
):
void
{
const
classes
=
[
'
monaco-icon-label
'
];
if
(
options
)
{
if
(
options
.
extraClasses
)
{
...
...
@@ -131,11 +136,7 @@ export class IconLabel extends Disposable {
this
.
domNode
.
className
=
classes
.
join
(
'
'
);
this
.
domNode
.
title
=
options
?.
title
||
''
;
if
(
this
.
labelNode
instanceof
HighlightedLabel
)
{
this
.
labelNode
.
set
(
label
||
''
,
options
?.
matches
,
options
?.
title
,
options
?.
labelEscapeNewLines
);
}
else
{
this
.
labelNode
.
textContent
=
label
||
''
;
}
this
.
nameNode
.
setLabel
(
label
,
options
);
if
(
description
||
this
.
descriptionNode
)
{
if
(
!
this
.
descriptionNode
)
{
...
...
@@ -157,3 +158,80 @@ export class IconLabel extends Disposable {
}
}
}
class
Label
{
private
label
:
string
|
string
[]
|
undefined
=
undefined
;
private
singleLabel
:
HTMLElement
|
undefined
=
undefined
;
constructor
(
private
container
:
HTMLElement
)
{
}
setLabel
(
label
:
string
|
string
[],
options
?:
IIconLabelValueOptions
):
void
{
if
(
this
.
label
===
label
)
{
return
;
}
this
.
label
=
label
;
if
(
typeof
label
===
'
string
'
)
{
if
(
!
this
.
singleLabel
)
{
this
.
container
.
innerHTML
=
''
;
this
.
singleLabel
=
dom
.
append
(
this
.
container
,
dom
.
$
(
'
a.label-name
'
));
}
this
.
singleLabel
.
textContent
=
label
;
}
else
{
this
.
container
.
innerHTML
=
''
;
this
.
singleLabel
=
undefined
;
for
(
let
i
=
0
;
i
<
label
.
length
;
i
++
)
{
const
l
=
label
[
i
];
dom
.
append
(
this
.
container
,
dom
.
$
(
'
a.label-name
'
,
undefined
,
l
));
if
(
i
<
label
.
length
-
1
)
{
dom
.
append
(
this
.
container
,
dom
.
$
(
'
span.label-separator
'
,
undefined
,
options
?.
separator
||
'
/
'
));
}
}
}
}
}
class
LabelWithHighlights
{
private
label
:
string
|
string
[]
|
undefined
=
undefined
;
private
singleLabel
:
HighlightedLabel
|
undefined
=
undefined
;
constructor
(
private
container
:
HTMLElement
,
private
supportCodicons
:
boolean
)
{
}
setLabel
(
label
:
string
|
string
[],
options
?:
IIconLabelValueOptions
):
void
{
if
(
this
.
label
===
label
)
{
return
;
}
this
.
label
=
label
;
if
(
typeof
label
===
'
string
'
)
{
if
(
!
this
.
singleLabel
)
{
this
.
container
.
innerHTML
=
''
;
this
.
singleLabel
=
new
HighlightedLabel
(
dom
.
append
(
this
.
container
,
dom
.
$
(
'
a.label-name
'
)),
this
.
supportCodicons
);
}
this
.
singleLabel
.
set
(
label
,
options
?.
matches
,
options
?.
title
,
options
?.
labelEscapeNewLines
);
}
else
{
this
.
container
.
innerHTML
=
''
;
this
.
singleLabel
=
undefined
;
for
(
let
i
=
0
;
i
<
label
.
length
;
i
++
)
{
const
l
=
label
[
i
];
const
highlightedLabel
=
new
HighlightedLabel
(
dom
.
append
(
this
.
container
,
dom
.
$
(
'
a.label-name
'
)),
this
.
supportCodicons
);
highlightedLabel
.
set
(
l
,
options
?.
matches
,
options
?.
title
,
options
?.
labelEscapeNewLines
);
if
(
i
<
label
.
length
-
1
)
{
dom
.
append
(
this
.
container
,
dom
.
$
(
'
span.label-separator
'
,
undefined
,
options
?.
separator
||
'
/
'
));
}
}
}
}
}
src/vs/base/browser/ui/iconLabel/iconlabel.css
浏览文件 @
8bb358f2
...
...
@@ -31,25 +31,31 @@
flex-shrink
:
0
;
/* fix for https://github.com/Microsoft/vscode/issues/13787 */
}
.monaco-icon-label
>
.monaco-icon-label-description-container
{
overflow
:
hidden
;
/* this causes the label/description to shrink first if decorations are enabled */
.monaco-icon-label
>
.monaco-icon-label-container
{
min-width
:
0
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
flex
:
1
;
}
.monaco-icon-label
>
.monaco-icon-label-
description
-container
>
.label-name
{
.monaco-icon-label
>
.monaco-icon-label-
container
>
.monaco-icon-name
-container
>
.label-name
{
color
:
inherit
;
white-space
:
pre
;
/* enable to show labels that include multiple whitespaces */
}
.monaco-icon-label
>
.monaco-icon-label-description-container
>
.label-description
{
.monaco-icon-label
>
.monaco-icon-label-container
>
.monaco-icon-name-container
>
.label-separator
{
margin
:
0
0.2em
;
}
.monaco-icon-label
>
.monaco-icon-label-container
>
.monaco-icon-description-container
>
.label-description
{
opacity
:
.7
;
margin-left
:
0.5em
;
font-size
:
0.9em
;
white-space
:
pre
;
/* enable to show labels that include multiple whitespaces */
}
.monaco-icon-label.italic
>
.monaco-icon-label-
description
-container
>
.label-name
,
.monaco-icon-label.italic
>
.monaco-icon-
label-
description-container
>
.label-description
{
.monaco-icon-label.italic
>
.monaco-icon-label-
container
>
.monaco-icon-name
-container
>
.label-name
,
.monaco-icon-label.italic
>
.monaco-icon-description-container
>
.label-description
{
font-style
:
italic
;
}
...
...
@@ -58,7 +64,6 @@
font-size
:
90%
;
font-weight
:
600
;
padding
:
0
16px
0
5px
;
margin-left
:
auto
;
text-align
:
center
;
}
...
...
src/vs/workbench/browser/labels.ts
浏览文件 @
8bb358f2
...
...
@@ -28,7 +28,7 @@ import { withNullAsUndefined } from 'vs/base/common/types';
export
interface
IResourceLabelProps
{
resource
?:
URI
;
name
?:
string
;
name
?:
string
|
string
[]
;
description
?:
string
;
}
...
...
@@ -41,6 +41,7 @@ export interface IResourceLabelOptions extends IIconLabelValueOptions {
export
interface
IFileLabelOptions
extends
IResourceLabelOptions
{
hideLabel
?:
boolean
;
hidePath
?:
boolean
;
readonly
parentCount
?:
number
;
}
export
interface
IResourceLabel
extends
IDisposable
{
...
...
@@ -442,7 +443,8 @@ class ResourceLabelWidget extends IconLabel {
title
:
''
,
italic
:
this
.
options
&&
this
.
options
.
italic
,
matches
:
this
.
options
&&
this
.
options
.
matches
,
extraClasses
:
[]
extraClasses
:
[],
separator
:
this
.
options
?.
separator
};
const
resource
=
this
.
label
.
resource
;
...
...
src/vs/workbench/contrib/files/browser/views/explorerViewer.ts
浏览文件 @
8bb358f2
...
...
@@ -51,6 +51,7 @@ import { ITreeCompressionDelegate } from 'vs/base/browser/ui/tree/asyncDataTree'
import
{
ICompressibleTreeRenderer
}
from
'
vs/base/browser/ui/tree/objectTree
'
;
import
{
ICompressedTreeNode
}
from
'
vs/base/browser/ui/tree/compressedObjectTreeModel
'
;
import
{
VSBuffer
}
from
'
vs/base/common/buffer
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
export
class
ExplorerDelegate
implements
IListVirtualDelegate
<
ExplorerItem
>
{
...
...
@@ -132,7 +133,8 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
@
IContextViewService
private
readonly
contextViewService
:
IContextViewService
,
@
IThemeService
private
readonly
themeService
:
IThemeService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
,
@
IExplorerService
private
readonly
explorerService
:
IExplorerService
@
IExplorerService
private
readonly
explorerService
:
IExplorerService
,
@
ILabelService
private
readonly
labelService
:
ILabelService
)
{
this
.
config
=
this
.
configurationService
.
getValue
<
IFilesConfiguration
>
();
this
.
configListener
=
this
.
configurationService
.
onDidChangeConfiguration
(
e
=>
{
...
...
@@ -175,7 +177,7 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
templateData
.
elementDisposable
.
dispose
();
const
stat
=
node
.
element
.
elements
[
node
.
element
.
elements
.
length
-
1
];
const
label
=
node
.
element
.
elements
.
map
(
e
=>
e
.
name
)
.
join
(
'
/
'
)
;
const
label
=
node
.
element
.
elements
.
map
(
e
=>
e
.
name
);
const
editableData
=
this
.
explorerService
.
getEditableData
(
stat
);
// File Label
...
...
@@ -191,7 +193,7 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
}
}
private
renderStat
(
stat
:
ExplorerItem
,
label
:
string
,
filterData
:
FuzzyScore
|
undefined
,
templateData
:
IFileTemplateData
):
IDisposable
{
private
renderStat
(
stat
:
ExplorerItem
,
label
:
string
|
string
[]
,
filterData
:
FuzzyScore
|
undefined
,
templateData
:
IFileTemplateData
):
IDisposable
{
templateData
.
label
.
element
.
style
.
display
=
'
flex
'
;
const
extraClasses
=
[
'
explorer-item
'
];
if
(
this
.
explorerService
.
isCut
(
stat
))
{
...
...
@@ -202,7 +204,8 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
fileKind
:
stat
.
isRoot
?
FileKind
.
ROOT_FOLDER
:
stat
.
isDirectory
?
FileKind
.
FOLDER
:
FileKind
.
FILE
,
extraClasses
,
fileDecorations
:
this
.
config
.
explorer
.
decorations
,
matches
:
createMatches
(
filterData
)
matches
:
createMatches
(
filterData
),
separator
:
this
.
labelService
.
getSeparator
(
stat
.
resource
.
scheme
,
stat
.
resource
.
authority
)
});
return
templateData
.
label
.
onDidRender
(()
=>
{
...
...
src/vs/workbench/contrib/scm/browser/media/scmViewlet.css
浏览文件 @
8bb358f2
...
...
@@ -135,6 +135,7 @@
.scm-viewlet
.monaco-list
.monaco-list-row
.resource-group
>
.actions
,
.scm-viewlet
.monaco-list
.monaco-list-row
.resource
>
.name
>
.monaco-icon-label
>
.actions
{
display
:
none
;
max-width
:
fit-content
;
}
.scm-viewlet
.monaco-list
.monaco-list-row
:hover
.resource-group
>
.actions
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录