Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b075690c
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,发现更多精彩内容 >>
提交
b075690c
编写于
6月 18, 2019
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
setting: workbench.tree.renderIndentGuides
上级
c516a4f2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
70 addition
and
6 deletion
+70
-6
src/vs/base/browser/ui/tree/abstractTree.ts
src/vs/base/browser/ui/tree/abstractTree.ts
+59
-6
src/vs/platform/list/browser/listService.ts
src/vs/platform/list/browser/listService.ts
+11
-0
未找到文件。
src/vs/base/browser/ui/tree/abstractTree.ts
浏览文件 @
b075690c
...
...
@@ -197,6 +197,7 @@ interface ITreeListTemplateData<T> {
interface
ITreeRendererOptions
{
readonly
indent
?:
number
;
readonly
renderIndentGuides
?:
boolean
;
}
interface
IRenderData
<
TTemplateData
>
{
...
...
@@ -204,6 +205,28 @@ interface IRenderData<TTemplateData> {
height
:
number
;
}
interface
Collection
<
T
>
{
readonly
elements
:
T
[];
readonly
onDidChange
:
Event
<
T
[]
>
;
}
class
EventCollection
<
T
>
implements
Collection
<
T
>
{
private
disposables
=
new
DisposableStore
();
get
elements
():
T
[]
{
return
this
.
_elements
;
}
constructor
(
readonly
onDidChange
:
Event
<
T
[]
>
,
private
_elements
:
T
[]
=
[])
{
onDidChange
(
e
=>
this
.
_elements
=
e
,
null
,
this
.
disposables
);
}
dispose
()
{
this
.
disposables
.
dispose
();
}
}
class
TreeRenderer
<
T
,
TFilterData
,
TTemplateData
>
implements
IListRenderer
<
ITreeNode
<
T
,
TFilterData
>
,
ITreeListTemplateData
<
TTemplateData
>>
{
private
static
DefaultIndent
=
8
;
...
...
@@ -212,14 +235,18 @@ class TreeRenderer<T, TFilterData, TTemplateData> implements IListRenderer<ITree
private
renderedElements
=
new
Map
<
T
,
ITreeNode
<
T
,
TFilterData
>>
();
private
renderedNodes
=
new
Map
<
ITreeNode
<
T
,
TFilterData
>
,
IRenderData
<
TTemplateData
>>
();
private
indent
:
number
=
TreeRenderer
.
DefaultIndent
;
private
_renderIndentGuides
=
false
;
private
renderedIndentGuides
=
new
SetMap
<
ITreeNode
<
T
,
TFilterData
>
,
SVGLineElement
>
();
private
activeParentNodes
=
new
Set
<
ITreeNode
<
T
,
TFilterData
>>
();
private
indentGuidesDisposable
:
IDisposable
=
Disposable
.
None
;
private
disposables
:
IDisposable
[]
=
[];
constructor
(
private
renderer
:
ITreeRenderer
<
T
,
TFilterData
,
TTemplateData
>
,
onDidChangeCollapseState
:
Event
<
ICollapseStateChangeEvent
<
T
,
TFilterData
>>
,
onDidChangeActiveNodes
:
Event
<
ITreeNode
<
T
,
TFilterData
>
[]
>
,
private
activeNodes
:
Collection
<
ITreeNode
<
T
,
TFilterData
>
>
,
options
:
ITreeRendererOptions
=
{}
)
{
this
.
templateId
=
renderer
.
templateId
;
...
...
@@ -230,14 +257,28 @@ class TreeRenderer<T, TFilterData, TTemplateData> implements IListRenderer<ITree
if
(
renderer
.
onDidChangeTwistieState
)
{
renderer
.
onDidChangeTwistieState
(
this
.
onDidChangeTwistieState
,
this
,
this
.
disposables
);
}
onDidChangeActiveNodes
(
this
.
onDidChangeActiveNodes
,
this
,
this
.
disposables
);
}
updateOptions
(
options
:
ITreeRendererOptions
=
{}):
void
{
if
(
typeof
options
.
indent
!==
'
undefined
'
)
{
this
.
indent
=
clamp
(
options
.
indent
,
0
,
40
);
}
const
renderIndentGuides
=
!!
options
.
renderIndentGuides
;
if
(
renderIndentGuides
!==
this
.
_renderIndentGuides
)
{
this
.
_renderIndentGuides
=
renderIndentGuides
;
if
(
renderIndentGuides
)
{
const
disposables
=
new
DisposableStore
();
this
.
activeNodes
.
onDidChange
(
this
.
_onDidChangeActiveNodes
,
this
,
disposables
);
this
.
indentGuidesDisposable
=
disposables
;
this
.
_onDidChangeActiveNodes
(
this
.
activeNodes
.
elements
);
}
else
{
this
.
indentGuidesDisposable
.
dispose
();
}
}
}
renderTemplate
(
container
:
HTMLElement
):
ITreeListTemplateData
<
TTemplateData
>
{
...
...
@@ -322,8 +363,12 @@ class TreeRenderer<T, TFilterData, TTemplateData> implements IListRenderer<ITree
}
}
// // TODO: only do iff indent guides are enabled
private
renderIndentGuides
(
target
:
ITreeNode
<
T
,
TFilterData
>
,
templateData
:
ITreeListTemplateData
<
TTemplateData
>
,
height
:
number
):
void
{
if
(
!
this
.
_renderIndentGuides
)
{
clearNode
(
templateData
.
indent
);
return
;
}
templateData
.
indentGuidesDisposable
.
dispose
();
const
disposableStore
=
new
DisposableStore
();
...
...
@@ -356,7 +401,11 @@ class TreeRenderer<T, TFilterData, TTemplateData> implements IListRenderer<ITree
templateData
.
indentGuidesDisposable
=
disposableStore
;
}
private
onDidChangeActiveNodes
(
nodes
:
ITreeNode
<
T
,
TFilterData
>
[]):
void
{
private
_onDidChangeActiveNodes
(
nodes
:
ITreeNode
<
T
,
TFilterData
>
[]):
void
{
if
(
!
this
.
_renderIndentGuides
)
{
return
;
}
const
set
=
new
Set
<
ITreeNode
<
T
,
TFilterData
>>
();
nodes
.
forEach
(
node
=>
{
...
...
@@ -383,6 +432,7 @@ class TreeRenderer<T, TFilterData, TTemplateData> implements IListRenderer<ITree
dispose
():
void
{
this
.
renderedNodes
.
clear
();
this
.
renderedElements
.
clear
();
this
.
indentGuidesDisposable
.
dispose
();
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
...
...
@@ -1136,7 +1186,10 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
const
onDidChangeCollapseStateRelay
=
new
Relay
<
ICollapseStateChangeEvent
<
T
,
TFilterData
>>
();
const
onDidChangeActiveNodes
=
new
Relay
<
ITreeNode
<
T
,
TFilterData
>
[]
>
();
this
.
renderers
=
renderers
.
map
(
r
=>
new
TreeRenderer
<
T
,
TFilterData
,
any
>
(
r
,
onDidChangeCollapseStateRelay
.
event
,
onDidChangeActiveNodes
.
event
,
_options
));
const
activeNodes
=
new
EventCollection
(
onDidChangeActiveNodes
.
event
);
this
.
disposables
.
push
(
activeNodes
);
this
.
renderers
=
renderers
.
map
(
r
=>
new
TreeRenderer
<
T
,
TFilterData
,
any
>
(
r
,
onDidChangeCollapseStateRelay
.
event
,
activeNodes
,
_options
));
this
.
disposables
.
push
(...
this
.
renderers
);
let
filter
:
TypeFilter
<
T
>
|
undefined
;
...
...
src/vs/platform/list/browser/listService.ts
浏览文件 @
b075690c
...
...
@@ -114,6 +114,7 @@ export const horizontalScrollingKey = 'workbench.list.horizontalScrolling';
export
const
keyboardNavigationSettingKey
=
'
workbench.list.keyboardNavigation
'
;
export
const
automaticKeyboardNavigationSettingKey
=
'
workbench.list.automaticKeyboardNavigation
'
;
const
treeIndentKey
=
'
workbench.tree.indent
'
;
const
treeRenderIndentGuidesKey
=
'
workbench.tree.renderIndentGuides
'
;
function
getHorizontalScrollingSetting
(
configurationService
:
IConfigurationService
):
boolean
{
return
getMigratedSettingValue
<
boolean
>
(
configurationService
,
horizontalScrollingKey
,
'
workbench.tree.horizontalScrolling
'
);
...
...
@@ -897,6 +898,7 @@ function workbenchTreeDataPreamble<T, TFilterData>(
...
computeStyles
(
themeService
.
getTheme
(),
defaultListStyles
),
...
workbenchListOptions
,
indent
:
configurationService
.
getValue
<
number
>
(
treeIndentKey
),
renderIndentGuides
:
configurationService
.
getValue
<
boolean
>
(
treeRenderIndentGuidesKey
),
automaticKeyboardNavigation
:
getAutomaticKeyboardNavigation
(),
simpleKeyboardNavigation
:
keyboardNavigation
===
'
simple
'
,
filterOnType
:
keyboardNavigation
===
'
filter
'
,
...
...
@@ -977,6 +979,10 @@ class WorkbenchTreeInternals<TInput, T, TFilterData> {
const
indent
=
configurationService
.
getValue
<
number
>
(
treeIndentKey
);
tree
.
updateOptions
({
indent
});
}
if
(
e
.
affectsConfiguration
(
treeRenderIndentGuidesKey
))
{
const
renderIndentGuides
=
configurationService
.
getValue
<
boolean
>
(
treeRenderIndentGuidesKey
);
tree
.
updateOptions
({
renderIndentGuides
});
}
if
(
e
.
affectsConfiguration
(
keyboardNavigationSettingKey
))
{
updateKeyboardNavigation
();
}
...
...
@@ -1053,6 +1059,11 @@ configurationRegistry.registerConfiguration({
maximum
:
40
,
'
description
'
:
localize
(
'
tree indent setting
'
,
"
Controls tree indentation in pixels.
"
)
},
[
treeRenderIndentGuidesKey
]:
{
type
:
'
boolean
'
,
default
:
false
,
'
description
'
:
localize
(
'
render tree indent guides
'
,
"
Controls whether the tree should render indent guides.
"
)
},
[
keyboardNavigationSettingKey
]:
{
'
type
'
:
'
string
'
,
'
enum
'
:
[
'
simple
'
,
'
highlight
'
,
'
filter
'
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录