Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e39efb2a
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,发现更多精彩内容 >>
未验证
提交
e39efb2a
编写于
9月 14, 2018
作者:
C
Christopher Leidigh
提交者:
GitHub
9月 14, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SelectBox: Lazy list create on open. Pass 1 addressing #58236 (#58722)
上级
f5670e27
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
34 deletion
+53
-34
src/vs/base/browser/ui/selectBox/selectBoxCustom.ts
src/vs/base/browser/ui/selectBox/selectBoxCustom.ts
+53
-34
未找到文件。
src/vs/base/browser/ui/selectBox/selectBoxCustom.ts
浏览文件 @
e39efb2a
...
...
@@ -148,7 +148,13 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
this
.
registerListeners
();
this
.
constructSelectDropDown
(
contextViewProvider
);
this
.
setOptions
(
options
,
selected
);
this
.
selected
=
selected
||
0
;
// CDL check
if
(
options
)
{
this
.
setOptions
(
options
,
selected
);
}
}
// IDelegate - List renderer
...
...
@@ -168,8 +174,8 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
this
.
selectDropDownContainer
=
dom
.
$
(
'
.monaco-select-box-dropdown-container
'
);
// Use custom CSS vars for padding calculation (shared with parent select)
dom
.
addClass
(
this
.
selectDropDownContainer
,
'
monaco-select-box-dropdown-padding
'
);
// Setup list for drop-down select
this
.
createSelectList
(
this
.
selectDropDownContainer
);
// Setup container for select option details
this
.
selectionDetailsPane
=
dom
.
append
(
this
.
selectDropDownContainer
,
$
(
'
.select-box-details-pane
'
));
// Create span flex box item/div we can measure and control
...
...
@@ -254,27 +260,6 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
this
.
options
.
forEach
((
option
)
=>
{
this
.
selectElement
.
add
(
this
.
createOption
(
option
,
i
,
disabled
===
i
++
));
});
// Mirror options in drop-down
// Populate select list for non-native select mode
if
(
this
.
selectList
&&
!!
this
.
options
)
{
let
listEntries
:
ISelectOptionItem
[];
listEntries
=
[];
if
(
disabled
!==
undefined
)
{
this
.
disabledOptionIndex
=
disabled
;
}
for
(
let
index
=
0
;
index
<
this
.
options
.
length
;
index
++
)
{
const
element
=
this
.
options
[
index
];
let
optionDisabled
:
boolean
;
index
===
this
.
disabledOptionIndex
?
optionDisabled
=
true
:
optionDisabled
=
false
;
const
optionDescription
=
this
.
detailsProvider
?
this
.
detailsProvider
(
index
)
:
{
details
:
null
,
isMarkdown
:
false
};
listEntries
.
push
({
optionText
:
element
,
optionDisabled
:
optionDisabled
,
optionDescriptionText
:
optionDescription
.
details
});
}
this
.
selectList
.
splice
(
0
,
this
.
selectList
.
length
,
listEntries
);
}
}
if
(
selected
!==
undefined
)
{
...
...
@@ -284,6 +269,27 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
}
}
private
setOptionsList
()
{
// Mirror options in drop-down
// Populate select list for non-native select mode
if
(
this
.
selectList
&&
!!
this
.
options
)
{
let
listEntries
:
ISelectOptionItem
[];
listEntries
=
[];
for
(
let
index
=
0
;
index
<
this
.
options
.
length
;
index
++
)
{
const
element
=
this
.
options
[
index
];
let
optionDisabled
:
boolean
;
index
===
this
.
disabledOptionIndex
?
optionDisabled
=
true
:
optionDisabled
=
false
;
const
optionDescription
=
this
.
detailsProvider
?
this
.
detailsProvider
(
index
)
:
{
details
:
null
,
isMarkdown
:
false
};
listEntries
.
push
({
optionText
:
element
,
optionDisabled
:
optionDisabled
,
optionDescriptionText
:
optionDescription
.
details
});
}
this
.
selectList
.
splice
(
0
,
this
.
selectList
.
length
,
listEntries
);
}
}
public
select
(
index
:
number
):
void
{
if
(
index
>=
0
&&
index
<
this
.
options
.
length
)
{
...
...
@@ -303,19 +309,10 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
public
setAriaLabel
(
label
:
string
):
void
{
this
.
selectBoxOptions
.
ariaLabel
=
label
;
this
.
selectElement
.
setAttribute
(
'
aria-label
'
,
this
.
selectBoxOptions
.
ariaLabel
);
this
.
selectList
.
getHTMLElement
().
setAttribute
(
'
aria-label
'
,
this
.
selectBoxOptions
.
ariaLabel
);
}
public
setDetailsProvider
(
provider
:
(
index
:
number
)
=>
{
details
:
string
,
isMarkdown
:
boolean
}):
void
{
this
.
detailsProvider
=
provider
;
if
(
this
.
options
)
{
const
currentOptions
=
this
.
options
;
this
.
options
=
[];
this
.
setOptions
(
currentOptions
,
this
.
selected
,
this
.
disabledOptionIndex
);
}
}
public
focus
():
void
{
...
...
@@ -333,7 +330,6 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
public
render
(
container
:
HTMLElement
):
void
{
dom
.
addClass
(
container
,
'
select-container
'
);
container
.
appendChild
(
this
.
selectElement
);
this
.
setOptions
(
this
.
options
,
this
.
selected
);
this
.
applyStyles
();
}
...
...
@@ -411,6 +407,15 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
// Style drop down select list (non-native mode only)
if
(
this
.
selectList
)
{
this
.
styleList
();
}
}
private
styleList
()
{
if
(
this
.
selectList
)
{
let
background
=
null
;
background
=
this
.
styles
.
selectBackground
?
this
.
styles
.
selectBackground
.
toString
()
:
null
;
this
.
selectList
.
style
({});
let
listBackground
=
this
.
styles
.
selectListBackground
?
this
.
styles
.
selectListBackground
.
toString
()
:
background
;
...
...
@@ -434,10 +439,15 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
// ContextView dropdown methods
private
showSelectDropDown
()
{
if
(
!
this
.
contextViewProvider
||
this
.
_isVisible
)
{
return
;
}
// Lazily create and populate list only at open, moved from constructor
this
.
createSelectList
(
this
.
selectDropDownContainer
);
this
.
setOptionsList
();
this
.
cloneElementFont
(
this
.
selectElement
,
this
.
selectDropDownContainer
);
// This allows us to flip the position based on measurement
...
...
@@ -730,6 +740,11 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
private
createSelectList
(
parent
:
HTMLElement
):
void
{
// If we have already constructive list on open, skip
if
(
this
.
selectList
)
{
return
;
}
// SetUp container for list
this
.
selectDropDownListContainer
=
dom
.
append
(
parent
,
$
(
'
.select-box-dropdown-list-container
'
));
...
...
@@ -771,7 +786,10 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
this
.
selectList
.
onFocusChange
(
e
=>
this
.
onListFocus
(
e
))
);
this
.
selectList
.
getHTMLElement
().
setAttribute
(
'
aria-label
'
,
this
.
selectBoxOptions
.
ariaLabel
);
this
.
selectList
.
getHTMLElement
().
setAttribute
(
'
aria-expanded
'
,
'
true
'
);
this
.
styleList
();
}
// List methods
...
...
@@ -855,6 +873,7 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
if
(
!
this
.
_isVisible
)
{
return
;
}
this
.
selectionDetailsPane
.
innerText
=
''
;
const
selectedIndex
=
e
.
indexes
[
0
];
let
description
=
this
.
detailsProvider
?
this
.
detailsProvider
(
selectedIndex
)
:
{
details
:
''
,
isMarkdown
:
false
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录