Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9134f9fd
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,发现更多精彩内容 >>
提交
9134f9fd
编写于
11月 14, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some mirco optimizations for CodeLensWidget, #84726
上级
e1983faa
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
30 deletion
+37
-30
src/vs/editor/contrib/codelens/codelensWidget.ts
src/vs/editor/contrib/codelens/codelensWidget.ts
+37
-30
未找到文件。
src/vs/editor/contrib/codelens/codelensWidget.ts
浏览文件 @
9134f9fd
...
...
@@ -5,7 +5,6 @@
import
'
vs/css!./codelensWidget
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
coalesce
,
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
renderCodicons
}
from
'
vs/base/browser/ui/codiconLabel/codiconLabel
'
;
import
*
as
editorBrowser
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -66,7 +65,7 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
constructor
(
editor
:
editorBrowser
.
ICodeEditor
,
symbolRange
:
Range
,
data
:
CodeLensItem
[]
lenses
:
Array
<
CodeLens
|
undefined
|
null
>
)
{
this
.
_id
=
'
codeLensWidget
'
+
(
++
CodeLensContentWidget
.
_idPool
);
this
.
_editor
=
editor
;
...
...
@@ -74,10 +73,9 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
this
.
setSymbolRange
(
symbolRange
);
this
.
_domNode
=
document
.
createElement
(
'
span
'
);
this
.
_domNode
.
innerHTML
=
'
'
;
dom
.
addClass
(
this
.
_domNode
,
'
codelens-decoration
'
);
this
.
_domNode
.
className
=
'
codelens-decoration
'
;
this
.
updateHeight
();
this
.
withCommands
(
data
.
map
(
data
=>
data
.
symbol
)
,
false
);
this
.
withCommands
(
lenses
,
false
);
}
updateHeight
():
void
{
...
...
@@ -88,39 +86,45 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
this
.
_domNode
.
style
.
lineHeight
=
`
${
lineHeight
}
px`
;
this
.
_domNode
.
style
.
fontSize
=
`
${
Math
.
round
(
fontInfo
.
fontSize
*
0.9
)}
px`
;
this
.
_domNode
.
style
.
paddingRight
=
`
${
Math
.
round
(
fontInfo
.
fontSize
*
0.45
)}
px`
;
this
.
_domNode
.
innerHTML
=
'
'
;
}
withCommands
(
inSymbol
s
:
Array
<
CodeLens
|
undefined
|
null
>
,
animate
:
boolean
):
void
{
withCommands
(
lense
s
:
Array
<
CodeLens
|
undefined
|
null
>
,
animate
:
boolean
):
void
{
this
.
_commands
.
clear
();
const
symbols
=
coalesce
(
inSymbols
);
if
(
isFalsyOrEmpty
(
symbols
))
{
this
.
_domNode
.
innerHTML
=
'
<span>no commands</span>
'
;
return
;
}
let
html
:
string
[]
=
[];
for
(
let
i
=
0
;
i
<
symbols
.
length
;
i
++
)
{
const
command
=
symbols
[
i
].
command
;
if
(
command
)
{
const
title
=
renderCodicons
(
command
.
title
);
let
part
:
string
;
if
(
command
.
id
)
{
part
=
`<a id=
${
i
}
>
${
title
}
</a>`
;
this
.
_commands
.
set
(
String
(
i
),
command
);
let
innerHtml
=
''
;
let
hasSymbol
=
false
;
for
(
let
i
=
0
;
i
<
lenses
.
length
;
i
++
)
{
const
lens
=
lenses
[
i
];
if
(
!
lens
)
{
continue
;
}
hasSymbol
=
true
;
if
(
lens
.
command
)
{
const
title
=
renderCodicons
(
lens
.
command
.
title
);
if
(
lens
.
command
.
id
)
{
innerHtml
+=
`<a id=
${
i
}
>
${
title
}
</a>`
;
this
.
_commands
.
set
(
String
(
i
),
lens
.
command
);
}
else
{
part
=
`<span>
${
title
}
</span>`
;
innerHtml
+=
`<span>
${
title
}
</span>`
;
}
if
(
i
+
1
<
lenses
.
length
)
{
innerHtml
+=
'
<span> | </span>
'
;
}
html
.
push
(
part
);
}
}
const
wasEmpty
=
this
.
_domNode
.
innerHTML
===
''
||
this
.
_domNode
.
innerHTML
===
'
'
;
this
.
_domNode
.
innerHTML
=
html
.
join
(
'
<span> | </span>
'
);
this
.
_editor
.
layoutContentWidget
(
this
);
if
(
wasEmpty
&&
animate
)
{
dom
.
addClass
(
this
.
_domNode
,
'
fadein
'
);
if
(
!
hasSymbol
)
{
// symbols but no commands
this
.
_domNode
.
innerHTML
=
'
<span>no commands</span>
'
;
}
else
{
// symbols and commands
const
wasEmpty
=
this
.
_domNode
.
innerHTML
===
''
||
this
.
_domNode
.
innerHTML
===
'
'
;
this
.
_domNode
.
innerHTML
=
innerHtml
||
'
'
;
this
.
_editor
.
layoutContentWidget
(
this
);
if
(
wasEmpty
&&
animate
)
{
dom
.
addClass
(
this
.
_domNode
,
'
fadein
'
);
}
}
}
...
...
@@ -213,8 +217,11 @@ export class CodeLensWidget {
this
.
_decorationIds
=
new
Array
<
string
>
(
this
.
_data
.
length
);
let
range
:
Range
|
undefined
;
let
lenses
:
CodeLens
[]
=
[];
this
.
_data
.
forEach
((
codeLensData
,
i
)
=>
{
lenses
.
push
(
codeLensData
.
symbol
);
helper
.
addDecoration
({
range
:
codeLensData
.
symbol
.
range
,
options
:
ModelDecorationOptions
.
EMPTY
...
...
@@ -229,7 +236,7 @@ export class CodeLensWidget {
});
if
(
range
)
{
this
.
_contentWidget
=
new
CodeLensContentWidget
(
editor
,
range
,
this
.
_data
);
this
.
_contentWidget
=
new
CodeLensContentWidget
(
editor
,
range
,
lenses
);
this
.
_viewZone
=
new
CodeLensViewZone
(
range
.
startLineNumber
-
1
,
updateCallback
);
this
.
_viewZoneId
=
viewZoneChangeAccessor
.
addZone
(
this
.
_viewZone
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录