Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ad9e2707
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,发现更多精彩内容 >>
未验证
提交
ad9e2707
编写于
10月 21, 2019
作者:
J
João Moreno
提交者:
GitHub
10月 21, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #82981 from microsoft/joao/cached-list-virtual-delegate
Extract CachedListVirtualDelegate
上级
4225aa8a
dff18ede
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
47 deletion
+44
-47
src/vs/base/browser/ui/list/list.ts
src/vs/base/browser/ui/list/list.ts
+16
-0
src/vs/workbench/contrib/debug/browser/repl.ts
src/vs/workbench/contrib/debug/browser/repl.ts
+16
-21
src/vs/workbench/contrib/preferences/browser/settingsTree.ts
src/vs/workbench/contrib/preferences/browser/settingsTree.ts
+12
-26
未找到文件。
src/vs/base/browser/ui/list/list.ts
浏览文件 @
ad9e2707
...
...
@@ -115,3 +115,19 @@ export class ListError extends Error {
super
(
`ListError [
${
user
}
]
${
message
}
`
);
}
}
export
abstract
class
CachedListVirtualDelegate
<
T
extends
object
>
implements
IListVirtualDelegate
<
T
>
{
private
cache
=
new
WeakMap
<
T
,
number
>
();
getHeight
(
element
:
T
):
number
{
return
this
.
cache
.
get
(
element
)
??
this
.
estimateHeight
(
element
);
}
protected
abstract
estimateHeight
(
element
:
T
):
number
;
abstract
getTemplateId
(
element
:
T
):
string
;
setDynamicHeight
(
element
:
T
,
height
:
number
):
void
{
this
.
cache
.
set
(
element
,
height
);
}
}
src/vs/workbench/contrib/debug/browser/repl.ts
浏览文件 @
ad9e2707
...
...
@@ -46,7 +46,7 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import
{
IAccessibilityProvider
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
Variable
}
from
'
vs/workbench/contrib/debug/common/debugModel
'
;
import
{
SimpleReplElement
,
RawObjectReplElement
,
ReplEvaluationInput
,
ReplEvaluationResult
}
from
'
vs/workbench/contrib/debug/common/replModel
'
;
import
{
I
ListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
Cached
ListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
ITreeRenderer
,
ITreeNode
,
ITreeContextMenuEvent
,
IAsyncDataSource
}
from
'
vs/base/browser/ui/tree/tree
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
renderExpressionValue
,
AbstractExpressionsRenderer
,
IExpressionTemplateData
,
renderVariable
,
IInputBoxOptions
}
from
'
vs/workbench/contrib/debug/browser/baseDebugView
'
;
...
...
@@ -795,29 +795,28 @@ class ReplRawObjectsRenderer implements ITreeRenderer<RawObjectReplElement, Fuzz
}
}
class
ReplDelegate
implements
I
ListVirtualDelegate
<
IReplElement
>
{
class
ReplDelegate
extends
Cached
ListVirtualDelegate
<
IReplElement
>
{
private
heightCache
=
new
WeakMap
<
IReplElement
,
number
>
();
constructor
(
private
configurationService
:
IConfigurationService
)
{
}
constructor
(
private
configurationService
:
IConfigurationService
)
{
super
();
}
getHeight
(
element
:
IReplElement
):
number
{
const
countNumberOfLines
=
(
str
:
string
)
=>
Math
.
max
(
1
,
(
str
&&
str
.
match
(
/
\r\n
|
\n
/g
)
||
[]).
length
);
const
hasValue
=
(
e
:
any
):
e
is
{
value
:
string
}
=>
typeof
e
.
value
===
'
string
'
;
// Give approximate heights. Repl has dynamic height so the tree will measure the actual height on its own.
const
config
=
this
.
configurationService
.
getValue
<
IDebugConfiguration
>
(
'
debug
'
);
const
{
fontSize
,
wordWrap
}
=
config
.
console
;
const
rowHeight
=
Math
.
ceil
(
1.4
*
fontSize
);
if
(
!
wordWrap
)
{
return
rowHeight
;
}
const
cachedHeight
=
this
.
heightCache
.
get
(
element
);
if
(
typeof
cachedHeight
===
'
number
'
)
{
return
cachedHeight
;
if
(
!
config
.
console
.
wordWrap
)
{
return
Math
.
ceil
(
1.4
*
config
.
console
.
fontSize
);
}
return
super
.
getHeight
(
element
);
}
protected
estimateHeight
(
element
:
IReplElement
):
number
{
const
config
=
this
.
configurationService
.
getValue
<
IDebugConfiguration
>
(
'
debug
'
);
const
rowHeight
=
Math
.
ceil
(
1.4
*
config
.
console
.
fontSize
);
const
countNumberOfLines
=
(
str
:
string
)
=>
Math
.
max
(
1
,
(
str
&&
str
.
match
(
/
\r\n
|
\n
/g
)
||
[]).
length
);
const
hasValue
=
(
e
:
any
):
e
is
{
value
:
string
}
=>
typeof
e
.
value
===
'
string
'
;
// Calculate a rough overestimation for the height
// For every 30 characters increase the number of lines needed
if
(
hasValue
(
element
))
{
...
...
@@ -852,10 +851,6 @@ class ReplDelegate implements IListVirtualDelegate<IReplElement> {
// Empty elements should not have dynamic height since they will be invisible
return
element
.
toString
().
length
>
0
;
}
setDynamicHeight
(
element
:
IReplElement
,
height
:
number
):
void
{
this
.
heightCache
.
set
(
element
,
height
);
}
}
function
isDebugSession
(
obj
:
any
):
obj
is
IDebugSession
{
...
...
src/vs/workbench/contrib/preferences/browser/settingsTree.ts
浏览文件 @
ad9e2707
...
...
@@ -12,7 +12,7 @@ import { alert as ariaAlert } from 'vs/base/browser/ui/aria/aria';
import
{
Button
}
from
'
vs/base/browser/ui/button/button
'
;
import
{
Checkbox
}
from
'
vs/base/browser/ui/checkbox/checkbox
'
;
import
{
InputBox
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
import
{
IListVirtualDelegate
,
ListAriaRootRol
e
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
ListAriaRootRole
,
CachedListVirtualDelegat
e
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
DefaultStyleController
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
ISelectOptionItem
,
SelectBox
}
from
'
vs/base/browser/ui/selectBox/selectBox
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
...
...
@@ -1379,29 +1379,7 @@ export class SettingsTreeFilter implements ITreeFilter<SettingsTreeElement> {
}
}
class
SettingsTreeDelegate
implements
IListVirtualDelegate
<
SettingsTreeGroupChild
>
{
private
heightCache
=
new
WeakMap
<
SettingsTreeGroupChild
,
number
>
();
getHeight
(
element
:
SettingsTreeGroupChild
):
number
{
const
cachedHeight
=
this
.
heightCache
.
get
(
element
);
if
(
typeof
cachedHeight
===
'
number
'
)
{
return
cachedHeight
;
}
if
(
element
instanceof
SettingsTreeGroupElement
)
{
if
(
element
.
isFirstGroup
)
{
return
31
;
}
return
40
+
(
7
*
element
.
level
);
}
return
element
instanceof
SettingsTreeSettingElement
&&
element
.
valueType
===
SettingValueType
.
Boolean
?
78
:
104
;
}
class
SettingsTreeDelegate
extends
CachedListVirtualDelegate
<
SettingsTreeGroupChild
>
{
getTemplateId
(
element
:
SettingsTreeGroupElement
|
SettingsTreeSettingElement
|
SettingsTreeNewExtensionsElement
):
string
{
if
(
element
instanceof
SettingsTreeGroupElement
)
{
...
...
@@ -1447,8 +1425,16 @@ class SettingsTreeDelegate implements IListVirtualDelegate<SettingsTreeGroupChil
return
!
(
element
instanceof
SettingsTreeGroupElement
);
}
setDynamicHeight
(
element
:
SettingsTreeGroupChild
,
height
:
number
):
void
{
this
.
heightCache
.
set
(
element
,
height
);
protected
estimateHeight
(
element
:
SettingsTreeGroupChild
):
number
{
if
(
element
instanceof
SettingsTreeGroupElement
)
{
if
(
element
.
isFirstGroup
)
{
return
31
;
}
return
40
+
(
7
*
element
.
level
);
}
return
element
instanceof
SettingsTreeSettingElement
&&
element
.
valueType
===
SettingValueType
.
Boolean
?
78
:
104
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录