Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8dda8cb9
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,发现更多精彩内容 >>
提交
8dda8cb9
编写于
8月 10, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Settings editor - reduce SearchResultModel special-casing
上级
3833a3de
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
34 deletion
+31
-34
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
...vs/workbench/parts/preferences/browser/settingsEditor2.ts
+4
-3
src/vs/workbench/parts/preferences/browser/settingsTree.ts
src/vs/workbench/parts/preferences/browser/settingsTree.ts
+26
-30
src/vs/workbench/parts/preferences/browser/tocTree.ts
src/vs/workbench/parts/preferences/browser/tocTree.ts
+1
-1
未找到文件。
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
浏览文件 @
8dda8cb9
...
...
@@ -606,7 +606,8 @@ export class SettingsEditor2 extends BaseEditor {
this
.
settingsTreeModel
.
update
(
resolvedSettingsRoot
);
return
this
.
refreshTree
();
}
else
{
this
.
settingsTreeModel
=
this
.
instantiationService
.
createInstance
(
SettingsTreeModel
,
this
.
viewState
,
resolvedSettingsRoot
);
this
.
settingsTreeModel
=
this
.
instantiationService
.
createInstance
(
SettingsTreeModel
,
this
.
viewState
);
this
.
settingsTreeModel
.
update
(
resolvedSettingsRoot
);
this
.
settingsTree
.
setInput
(
this
.
settingsTreeModel
.
root
);
this
.
tocTreeModel
.
settingsTreeRoot
=
this
.
settingsTreeModel
.
root
as
SettingsTreeGroupElement
;
...
...
@@ -688,7 +689,7 @@ export class SettingsEditor2 extends BaseEditor {
collapseAll
(
this
.
tocTree
);
if
(
this
.
searchResultModel
)
{
return
this
.
settingsTree
.
setInput
(
this
.
searchResultModel
);
return
this
.
settingsTree
.
setInput
(
this
.
searchResultModel
.
root
);
}
else
{
return
this
.
settingsTree
.
setInput
(
this
.
settingsTreeModel
.
root
);
}
...
...
@@ -780,7 +781,7 @@ export class SettingsEditor2 extends BaseEditor {
this
.
searchResultModel
.
setResult
(
type
,
result
);
this
.
tocTreeModel
.
currentSearchModel
=
this
.
searchResultModel
;
this
.
toggleSearchMode
();
this
.
settingsTree
.
setInput
(
this
.
searchResultModel
);
this
.
settingsTree
.
setInput
(
this
.
searchResultModel
.
root
);
}
else
{
this
.
searchResultModel
.
setResult
(
type
,
result
);
}
...
...
src/vs/workbench/parts/preferences/browser/settingsTree.ts
浏览文件 @
8dda8cb9
...
...
@@ -47,11 +47,11 @@ export const ONLINE_SERVICES_SETTING_TAG = 'usesOnlineServices';
export
abstract
class
SettingsTreeElement
{
id
:
string
;
parent
:
any
;
// SearchResultModel or group element... TODO search should be more similar to the normal case
parent
:
SettingsTreeGroupElement
;
}
export
class
SettingsTreeGroupElement
extends
SettingsTreeElement
{
children
:
(
SettingsTreeGroupElement
|
SettingsTreeSettingElement
)[];
children
:
(
SettingsTreeGroupElement
|
SettingsTreeSettingElement
|
SettingsTreeNewExtensionsElement
)[];
count
?:
number
;
label
:
string
;
level
:
number
;
...
...
@@ -118,17 +118,15 @@ export interface ITOCEntry {
}
export
class
SettingsTreeModel
{
pr
ivate
_root
:
SettingsTreeGroupElement
;
pr
otected
_root
:
SettingsTreeGroupElement
;
private
_treeElementsById
=
new
Map
<
string
,
SettingsTreeElement
>
();
private
_treeElementsBySettingName
=
new
Map
<
string
,
SettingsTreeElement
>
();
private
_tocRoot
:
ITOCEntry
;
constructor
(
private
_viewState
:
ISettingsEditorViewState
,
private
_tocRoot
:
ITOCEntry
,
@
IConfigurationService
private
_configurationService
:
IConfigurationService
)
{
this
.
update
(
this
.
_tocRoot
);
}
)
{
}
get
root
():
SettingsTreeGroupElement
{
return
this
.
_root
;
...
...
@@ -136,7 +134,9 @@ export class SettingsTreeModel {
update
(
newTocRoot
=
this
.
_tocRoot
):
void
{
const
newRoot
=
this
.
createSettingsTreeGroupElement
(
newTocRoot
);
(
<
SettingsTreeGroupElement
>
newRoot
.
children
[
0
]).
isFirstGroup
=
true
;
if
(
newRoot
.
children
[
0
]
instanceof
SettingsTreeGroupElement
)
{
(
<
SettingsTreeGroupElement
>
newRoot
.
children
[
0
]).
isFirstGroup
=
true
;
// TODO
}
if
(
this
.
_root
)
{
this
.
_root
.
children
=
newRoot
.
children
;
...
...
@@ -165,6 +165,8 @@ export class SettingsTreeModel {
}
else
if
(
tocEntry
.
settings
)
{
element
.
children
=
tocEntry
.
settings
.
map
(
s
=>
this
.
createSettingsTreeSettingElement
(
<
ISetting
>
s
,
element
))
.
filter
(
el
=>
el
.
setting
.
deprecationMessage
?
el
.
isConfigured
:
true
);
}
else
{
element
.
children
=
[];
}
this
.
_treeElementsById
.
set
(
element
.
id
,
element
);
...
...
@@ -191,7 +193,7 @@ function sanitizeId(id: string): string {
return
id
.
replace
(
/
[\.\/]
/
,
'
_
'
);
}
function
createSettingsTreeSettingElement
(
setting
:
ISetting
,
parent
:
Se
archResultModel
|
Se
ttingsTreeGroupElement
,
settingsTarget
:
SettingsTarget
,
configurationService
:
IConfigurationService
):
SettingsTreeSettingElement
{
function
createSettingsTreeSettingElement
(
setting
:
ISetting
,
parent
:
SettingsTreeGroupElement
,
settingsTarget
:
SettingsTarget
,
configurationService
:
IConfigurationService
):
SettingsTreeSettingElement
{
const
element
=
new
SettingsTreeSettingElement
();
element
.
id
=
sanitizeId
(
parent
.
id
+
'
_
'
+
setting
.
key
);
element
.
parent
=
parent
;
...
...
@@ -385,10 +387,6 @@ export class SettingsDataSource implements IDataSource {
}
hasChildren
(
tree
:
ITree
,
element
:
SettingsTreeElement
):
boolean
{
if
(
element
instanceof
SearchResultModel
)
{
return
true
;
}
if
(
element
instanceof
SettingsTreeGroupElement
)
{
return
true
;
}
...
...
@@ -401,9 +399,7 @@ export class SettingsDataSource implements IDataSource {
}
private
_getChildren
(
element
:
SettingsTreeElement
):
SettingsTreeElement
[]
{
if
(
element
instanceof
SearchResultModel
)
{
return
element
.
getChildren
();
}
else
if
(
element
instanceof
SettingsTreeGroupElement
)
{
if
(
element
instanceof
SettingsTreeGroupElement
)
{
return
element
.
children
;
}
else
{
// No children...
...
...
@@ -553,7 +549,7 @@ export class SettingsRenderer implements ITreeRenderer {
public
static
readonly
MAX_ENUM_DESCRIPTIONS
=
10
;
p
rivate
static
readonly
CONTROL_CLASS
=
'
setting-control-focus-target
'
;
p
ublic
static
readonly
CONTROL_CLASS
=
'
setting-control-focus-target
'
;
public
static
readonly
CONTROL_SELECTOR
=
'
.
'
+
SettingsRenderer
.
CONTROL_CLASS
;
private
readonly
_onDidChangeSetting
:
Emitter
<
ISettingChangeEvent
>
=
new
Emitter
<
ISettingChangeEvent
>
();
...
...
@@ -1386,21 +1382,19 @@ export enum SearchResultIdx {
NewExtensions
=
2
}
export
class
SearchResultModel
{
export
class
SearchResultModel
extends
SettingsTreeModel
{
private
rawSearchResults
:
ISearchResult
[];
private
cachedUniqueSearchResults
:
ISearchResult
[];
private
newExtensionSearchResults
:
ISearchResult
;
private
children
:
(
SettingsTreeSettingElement
|
SettingsTreeNewExtensionsElement
)[];
readonly
id
=
'
searchResultModel
'
;
constructor
(
private
_viewState
:
ISettingsEditorViewState
,
@
IConfigurationService
private
_configurationService
:
IConfigurationService
)
{
}
getChildren
():
(
SettingsTreeSettingElement
|
SettingsTreeNewExtensionsElement
)[]
{
return
this
.
children
;
viewState
:
ISettingsEditorViewState
,
@
IConfigurationService
configurationService
:
IConfigurationService
)
{
super
(
viewState
,
configurationService
);
this
.
update
({
id
:
'
searchResultModel
'
,
label
:
''
});
}
getUniqueResults
():
ISearchResult
[]
{
...
...
@@ -1446,20 +1440,22 @@ export class SearchResultModel {
}
updateChildren
():
void
{
this
.
children
=
this
.
getFlatSettings
()
.
map
(
s
=>
createSettingsTreeSettingElement
(
s
,
this
,
this
.
_viewState
.
settingsTarget
,
this
.
_configurationService
))
.
filter
(
el
=>
el
.
setting
.
deprecationMessage
?
el
.
isConfigured
:
true
);
this
.
update
({
id
:
'
searchResultModel
'
,
label
:
'
searchResultModel
'
,
settings
:
this
.
getFlatSettings
()
});
if
(
this
.
newExtensionSearchResults
)
{
const
newExtElement
=
new
SettingsTreeNewExtensionsElement
();
newExtElement
.
parent
=
this
;
newExtElement
.
parent
=
this
.
_root
;
newExtElement
.
id
=
'
newExtensions
'
;
const
resultExtensionIds
=
this
.
newExtensionSearchResults
.
filterMatches
.
map
(
result
=>
(
<
IExtensionSetting
>
result
.
setting
))
.
filter
(
setting
=>
setting
.
extensionName
&&
setting
.
extensionPublisher
)
.
map
(
setting
=>
`
${
setting
.
extensionPublisher
}
.
${
setting
.
extensionName
}
`
);
newExtElement
.
extensionIds
=
arrays
.
distinct
(
resultExtensionIds
);
this
.
children
.
push
(
newExtElement
);
this
.
_root
.
children
.
push
(
newExtElement
);
}
}
...
...
src/vs/workbench/parts/preferences/browser/tocTree.ts
浏览文件 @
8dda8cb9
...
...
@@ -60,7 +60,7 @@ export class TOCTreeModel {
}
private
getSearchResultChildrenCount
(
group
:
SettingsTreeGroupElement
):
number
{
return
this
.
_currentSearchModel
.
getChildren
()
.
filter
(
child
=>
{
return
this
.
_currentSearchModel
.
root
.
children
.
filter
(
child
=>
{
return
child
instanceof
SettingsTreeSettingElement
&&
this
.
groupContainsSetting
(
group
,
child
.
setting
);
}).
length
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录