Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
451b14c7
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,发现更多精彩内容 >>
提交
451b14c7
编写于
9月 07, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more efficient iconlabel
上级
ae2b0eb7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
91 addition
and
42 deletion
+91
-42
src/vs/base/browser/ui/iconLabel/iconLabel.ts
src/vs/base/browser/ui/iconLabel/iconLabel.ts
+88
-34
src/vs/base/browser/ui/iconLabel/iconlabel.css
src/vs/base/browser/ui/iconLabel/iconlabel.css
+0
-4
src/vs/workbench/browser/labels.ts
src/vs/workbench/browser/labels.ts
+2
-2
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
+1
-2
未找到文件。
src/vs/base/browser/ui/iconLabel/iconLabel.ts
浏览文件 @
451b14c7
...
...
@@ -12,6 +12,7 @@ import { IMatch } from 'vs/base/common/filters';
import
uri
from
'
vs/base/common/uri
'
;
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
{
IRootProvider
,
getPathLabel
,
IUserHomeProvider
}
from
'
vs/base/common/labels
'
;
import
{
IDisposable
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
interface
IIconLabelCreationOptions
{
supportHighlights
?:
boolean
;
...
...
@@ -24,56 +25,99 @@ export interface IIconLabelOptions {
matches
?:
IMatch
[];
}
class
FastLabelNode
{
private
disposed
:
boolean
;
private
_textContent
:
string
;
private
_className
:
string
;
private
_title
:
string
;
private
_empty
:
boolean
;
constructor
(
private
_element
:
HTMLElement
)
{
}
public
get
element
():
HTMLElement
{
return
this
.
_element
;
}
public
set
textContent
(
content
:
string
)
{
if
(
this
.
disposed
||
content
===
this
.
_textContent
)
{
return
;
}
this
.
_textContent
=
content
;
this
.
_element
.
textContent
=
content
;
}
public
set
className
(
className
:
string
)
{
if
(
this
.
disposed
||
className
===
this
.
_className
)
{
return
;
}
this
.
_className
=
className
;
this
.
_element
.
className
=
className
;
}
public
set
title
(
title
:
string
)
{
if
(
this
.
disposed
||
title
===
this
.
_title
)
{
return
;
}
this
.
_title
=
title
;
this
.
_element
.
title
=
title
;
}
public
set
empty
(
empty
:
boolean
)
{
if
(
this
.
disposed
||
empty
===
this
.
_empty
)
{
return
;
}
this
.
_empty
=
empty
;
this
.
_element
.
style
.
marginLeft
=
empty
?
'
0
'
:
null
;
}
public
dispose
():
void
{
this
.
disposed
=
true
;
}
}
export
class
IconLabel
{
private
domNode
:
HTMLElement
;
private
labelNode
:
HTMLElement
|
HighlightedLabel
;
private
descriptionNode
:
HTMLElement
;
private
domNode
:
FastLabelNode
;
private
labelNode
:
FastLabelNode
|
HighlightedLabel
;
private
descriptionNode
:
FastLabelNode
;
constructor
(
container
:
HTMLElement
,
options
?:
IIconLabelCreationOptions
)
{
this
.
domNode
=
dom
.
append
(
container
,
dom
.
$
(
'
.monaco-icon-label
'
));
this
.
domNode
=
new
FastLabelNode
(
dom
.
append
(
container
,
dom
.
$
(
'
.monaco-icon-label
'
)));
if
(
options
&&
options
.
supportHighlights
)
{
this
.
labelNode
=
new
HighlightedLabel
(
dom
.
append
(
this
.
domNode
,
dom
.
$
(
'
a.label-name
'
)));
this
.
labelNode
=
new
HighlightedLabel
(
dom
.
append
(
this
.
domNode
.
element
,
dom
.
$
(
'
a.label-name
'
)));
}
else
{
this
.
labelNode
=
dom
.
append
(
this
.
domNode
,
dom
.
$
(
'
a.label-name
'
));
this
.
labelNode
=
new
FastLabelNode
(
dom
.
append
(
this
.
domNode
.
element
,
dom
.
$
(
'
a.label-name
'
)
));
}
this
.
descriptionNode
=
dom
.
append
(
this
.
domNode
,
dom
.
$
(
'
span.label-description
'
));
this
.
descriptionNode
=
new
FastLabelNode
(
dom
.
append
(
this
.
domNode
.
element
,
dom
.
$
(
'
span.label-description
'
)));
}
public
get
element
():
HTMLElement
{
return
this
.
domNode
;
return
this
.
domNode
.
element
;
}
public
get
labelElement
():
HTMLElement
{
public
onClick
(
callback
:
(
event
:
MouseEvent
)
=>
void
):
IDisposable
{
return
combinedDisposable
([
dom
.
addDisposableListener
(
this
.
labelElement
,
dom
.
EventType
.
CLICK
,
(
e
:
MouseEvent
)
=>
callback
(
e
)),
dom
.
addDisposableListener
(
this
.
descriptionNode
.
element
,
dom
.
EventType
.
CLICK
,
(
e
:
MouseEvent
)
=>
callback
(
e
))
]);
}
private
get
labelElement
():
HTMLElement
{
const
labelNode
=
this
.
labelNode
;
if
(
labelNode
instanceof
HighlightedLabel
)
{
return
labelNode
.
element
;
}
else
{
return
labelNode
;
}
}
public
get
descriptionElement
():
HTMLElement
{
return
this
.
descriptionNode
;
return
labelNode
.
element
;
}
public
setValue
(
label
?:
string
,
description
?:
string
,
options
?:
IIconLabelOptions
):
void
{
const
labelNode
=
this
.
labelNode
;
if
(
labelNode
instanceof
HighlightedLabel
)
{
labelNode
.
set
(
label
||
''
,
options
?
options
.
matches
:
void
0
);
}
else
{
labelNode
.
textContent
=
label
||
''
;
}
this
.
descriptionNode
.
textContent
=
description
||
''
;
if
(
!
description
)
{
dom
.
addClass
(
this
.
descriptionNode
,
'
empty
'
);
}
else
{
dom
.
removeClass
(
this
.
descriptionNode
,
'
empty
'
);
}
this
.
domNode
.
title
=
options
&&
options
.
title
?
options
.
title
:
''
;
const
classes
=
[
'
monaco-icon-label
'
];
if
(
options
)
{
if
(
options
.
extraClasses
)
{
...
...
@@ -86,13 +130,23 @@ export class IconLabel {
}
this
.
domNode
.
className
=
classes
.
join
(
'
'
);
}
this
.
domNode
.
title
=
options
&&
options
.
title
?
options
.
title
:
''
;
public
dispose
():
void
{
const
labelNode
=
this
.
labelNode
;
if
(
labelNode
instanceof
HighlightedLabel
)
{
labelNode
.
dispose
();
labelNode
.
set
(
label
||
''
,
options
?
options
.
matches
:
void
0
);
}
else
{
labelNode
.
textContent
=
label
||
''
;
}
this
.
descriptionNode
.
textContent
=
description
||
''
;
this
.
descriptionNode
.
empty
=
!
description
;
}
public
dispose
():
void
{
this
.
domNode
.
dispose
();
this
.
labelNode
.
dispose
();
this
.
descriptionNode
.
dispose
();
}
}
...
...
src/vs/base/browser/ui/iconLabel/iconlabel.css
浏览文件 @
451b14c7
...
...
@@ -39,10 +39,6 @@
white-space
:
pre
;
/* enable to show labels that include multiple whitespaces */
}
.monaco-icon-label
>
.label-description.empty
{
margin-left
:
0
;
}
.monaco-icon-label.italic
>
.label-name
,
.monaco-icon-label.italic
>
.label-description
{
font-style
:
italic
;
...
...
src/vs/workbench/browser/labels.ts
浏览文件 @
451b14c7
...
...
@@ -73,8 +73,8 @@ export class ResourceLabel extends IconLabel {
return
;
// we need the resource to compare
}
if
(
e
.
oldModeId
===
PLAINTEXT_MODE_ID
)
{
return
;
// ignore transitions from no mode to specific mode because this happens each time a model is created
if
(
e
.
model
.
uri
.
scheme
===
Schemas
.
file
&&
e
.
oldModeId
===
PLAINTEXT_MODE_ID
)
{
return
;
// ignore transitions
in files
from no mode to specific mode because this happens each time a model is created
}
if
(
e
.
model
.
uri
.
toString
()
===
this
.
label
.
resource
.
toString
())
{
...
...
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
浏览文件 @
451b14c7
...
...
@@ -38,8 +38,7 @@ export class NoTabsTitleControl extends TitleControl {
// Editor Label
this
.
editorLabel
=
this
.
instantiationService
.
createInstance
(
EditorLabel
,
this
.
titleContainer
,
void
0
);
this
.
toUnbind
.
push
(
this
.
editorLabel
);
this
.
toUnbind
.
push
(
DOM
.
addDisposableListener
(
this
.
editorLabel
.
labelElement
,
DOM
.
EventType
.
CLICK
,
(
e
:
MouseEvent
)
=>
this
.
onTitleLabelClick
(
e
)));
this
.
toUnbind
.
push
(
DOM
.
addDisposableListener
(
this
.
editorLabel
.
descriptionElement
,
DOM
.
EventType
.
CLICK
,
(
e
:
MouseEvent
)
=>
this
.
onTitleLabelClick
(
e
)));
this
.
toUnbind
.
push
(
this
.
editorLabel
.
onClick
(
e
=>
this
.
onTitleLabelClick
(
e
)));
// Right Actions Container
const
actionsContainer
=
document
.
createElement
(
'
div
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录