Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8764eaf5
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,发现更多精彩内容 >>
提交
8764eaf5
编写于
3月 05, 2019
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #64749 - firstVisibleIndex in tree should consider element midpoint
上级
b7673fb6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
30 deletion
+12
-30
src/vs/base/browser/ui/list/listView.ts
src/vs/base/browser/ui/list/listView.ts
+9
-0
src/vs/workbench/contrib/preferences/electron-browser/settingsEditor2.ts
...h/contrib/preferences/electron-browser/settingsEditor2.ts
+3
-30
未找到文件。
src/vs/base/browser/ui/list/listView.ts
浏览文件 @
8764eaf5
...
@@ -445,6 +445,15 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
...
@@ -445,6 +445,15 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
get
firstVisibleIndex
():
number
{
get
firstVisibleIndex
():
number
{
const
range
=
this
.
getRenderRange
(
this
.
lastRenderTop
,
this
.
lastRenderHeight
);
const
range
=
this
.
getRenderRange
(
this
.
lastRenderTop
,
this
.
lastRenderHeight
);
const
firstElTop
=
this
.
rangeMap
.
positionAt
(
range
.
start
);
const
nextElTop
=
this
.
rangeMap
.
positionAt
(
range
.
start
+
1
);
if
(
nextElTop
!==
-
1
)
{
const
firstElMidpoint
=
(
nextElTop
-
firstElTop
)
/
2
+
firstElTop
;
if
(
firstElMidpoint
<
this
.
scrollTop
)
{
return
range
.
start
+
1
;
}
}
return
range
.
start
;
return
range
.
start
;
}
}
...
...
src/vs/workbench/contrib/preferences/electron-browser/settingsEditor2.ts
浏览文件 @
8764eaf5
...
@@ -273,9 +273,6 @@ export class SettingsEditor2 extends BaseEditor {
...
@@ -273,9 +273,6 @@ export class SettingsEditor2 extends BaseEditor {
}
}
layout
(
dimension
:
DOM
.
Dimension
):
void
{
layout
(
dimension
:
DOM
.
Dimension
):
void
{
// const firstEl = this.settingsTree.getFirstVisibleElement();
// const firstElTop = this.settingsTree.getRelativeTop(firstEl);
this
.
layoutTrees
(
dimension
);
this
.
layoutTrees
(
dimension
);
const
innerWidth
=
dimension
.
width
-
24
*
2
;
// 24px padding on left and right
const
innerWidth
=
dimension
.
width
-
24
*
2
;
// 24px padding on left and right
...
@@ -497,7 +494,7 @@ export class SettingsEditor2 extends BaseEditor {
...
@@ -497,7 +494,7 @@ export class SettingsEditor2 extends BaseEditor {
e
=>
{
e
=>
{
if
(
DOM
.
findParentWithClass
(
e
.
relatedTarget
,
'
settings-editor-tree
'
))
{
if
(
DOM
.
findParentWithClass
(
e
.
relatedTarget
,
'
settings-editor-tree
'
))
{
if
(
this
.
settingsTree
.
scrollTop
>
0
)
{
if
(
this
.
settingsTree
.
scrollTop
>
0
)
{
const
firstElement
=
this
.
getFirstVisibleElement
()
;
const
firstElement
=
this
.
settingsTree
.
firstVisibleElement
;
this
.
settingsTree
.
reveal
(
firstElement
,
0.1
);
this
.
settingsTree
.
reveal
(
firstElement
,
0.1
);
return
true
;
return
true
;
}
}
...
@@ -519,7 +516,7 @@ export class SettingsEditor2 extends BaseEditor {
...
@@ -519,7 +516,7 @@ export class SettingsEditor2 extends BaseEditor {
e
=>
{
e
=>
{
if
(
DOM
.
findParentWithClass
(
e
.
relatedTarget
,
'
settings-editor-tree
'
))
{
if
(
DOM
.
findParentWithClass
(
e
.
relatedTarget
,
'
settings-editor-tree
'
))
{
if
(
this
.
settingsTree
.
scrollTop
<
this
.
settingsTree
.
scrollHeight
)
{
if
(
this
.
settingsTree
.
scrollTop
<
this
.
settingsTree
.
scrollHeight
)
{
const
lastElement
=
this
.
getLastVisibleElement
()
;
const
lastElement
=
this
.
settingsTree
.
lastVisibleElement
;
this
.
settingsTree
.
reveal
(
lastElement
,
0.9
);
this
.
settingsTree
.
reveal
(
lastElement
,
0.9
);
return
true
;
return
true
;
}
}
...
@@ -531,30 +528,6 @@ export class SettingsEditor2 extends BaseEditor {
...
@@ -531,30 +528,6 @@ export class SettingsEditor2 extends BaseEditor {
);
);
}
}
private
getFirstVisibleElement
(
nth
=
0
):
SettingsTreeElement
|
null
{
// Hack, see https://github.com/Microsoft/vscode/issues/64749
const
settingItems
=
this
.
settingsTree
.
getHTMLElement
().
querySelectorAll
(
AbstractSettingRenderer
.
CONTENTS_SELECTOR
);
const
firstEl
=
settingItems
[
nth
]
||
settingItems
[
0
];
if
(
!
firstEl
)
{
return
null
;
}
const
firstSettingId
=
this
.
settingRenderers
.
getIdForDOMElementInSetting
(
<
HTMLElement
>
firstEl
);
return
this
.
settingsTreeModel
.
getElementById
(
firstSettingId
);
}
private
getLastVisibleElement
():
SettingsTreeElement
|
null
{
// Hack, see https://github.com/Microsoft/vscode/issues/64749
const
settingItems
=
this
.
settingsTree
.
getHTMLElement
().
querySelectorAll
(
AbstractSettingRenderer
.
CONTENTS_SELECTOR
);
const
firstEl
=
settingItems
[
settingItems
.
length
-
1
];
if
(
!
firstEl
)
{
return
null
;
}
const
firstSettingId
=
this
.
settingRenderers
.
getIdForDOMElementInSetting
(
<
HTMLElement
>
firstEl
);
return
this
.
settingsTreeModel
.
getElementById
(
firstSettingId
);
}
private
createFocusSink
(
container
:
HTMLElement
,
callback
:
(
e
:
any
)
=>
boolean
,
label
:
string
):
HTMLElement
{
private
createFocusSink
(
container
:
HTMLElement
,
callback
:
(
e
:
any
)
=>
boolean
,
label
:
string
):
HTMLElement
{
const
listFocusSink
=
DOM
.
append
(
container
,
$
(
'
.settings-tree-focus-sink
'
));
const
listFocusSink
=
DOM
.
append
(
container
,
$
(
'
.settings-tree-focus-sink
'
));
listFocusSink
.
setAttribute
(
'
aria-label
'
,
label
);
listFocusSink
.
setAttribute
(
'
aria-label
'
,
label
);
...
@@ -688,7 +661,7 @@ export class SettingsEditor2 extends BaseEditor {
...
@@ -688,7 +661,7 @@ export class SettingsEditor2 extends BaseEditor {
return
;
return
;
}
}
const
elementToSync
=
this
.
getFirstVisibleElement
(
1
)
;
const
elementToSync
=
this
.
settingsTree
.
firstVisibleElement
;
const
element
=
elementToSync
instanceof
SettingsTreeSettingElement
?
elementToSync
.
parent
:
const
element
=
elementToSync
instanceof
SettingsTreeSettingElement
?
elementToSync
.
parent
:
elementToSync
instanceof
SettingsTreeGroupElement
?
elementToSync
:
elementToSync
instanceof
SettingsTreeGroupElement
?
elementToSync
:
null
;
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录