Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1269a996
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,发现更多精彩内容 >>
提交
1269a996
编写于
5月 22, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Settings editor - hook up search to tree
上级
c181b7c0
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
78 addition
and
66 deletion
+78
-66
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
...vs/workbench/parts/preferences/browser/settingsEditor2.ts
+45
-51
src/vs/workbench/parts/preferences/browser/settingsTree.ts
src/vs/workbench/parts/preferences/browser/settingsTree.ts
+33
-15
未找到文件。
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
浏览文件 @
1269a996
...
...
@@ -28,7 +28,7 @@ import { IThemeService, registerThemingParticipant, ICssStyleCollector, ITheme }
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
SearchWidget
,
SettingsTarget
,
SettingsTargetsWidget
}
from
'
vs/workbench/parts/preferences/browser/preferencesWidgets
'
;
import
{
IPreferencesService
,
ISearchResult
,
ISetting
,
ISettingsEditorModel
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
IPreferencesService
,
ISearchResult
,
ISetting
,
ISettingsEditorModel
,
ISettingsGroup
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
SettingsEditor2Input
}
from
'
vs/workbench/services/preferences/common/preferencesEditorInput
'
;
import
{
DefaultSettingsEditorModel
}
from
'
vs/workbench/services/preferences/common/preferencesModels
'
;
import
{
IPreferencesSearchService
,
ISearchProvider
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
...
...
@@ -175,7 +175,7 @@ export class SettingsEditor2 extends BaseEditor {
placeholder
:
localize
(
'
SearchSettings.Placeholder
'
,
"
Search settings
"
),
focusKey
:
this
.
searchFocusContextKey
}));
this
.
_register
(
this
.
searchWidget
.
onDidChange
(()
=>
this
.
onInputChanged
()));
this
.
_register
(
this
.
searchWidget
.
onDidChange
(()
=>
this
.
on
Search
InputChanged
()));
// this._register(DOM.addStandardDisposableListener(this.searchWidget.domNode, 'keydown', e => {
// if (e.keyCode === KeyCode.DownArrow) {
// this.settingsList.focusFirst();
...
...
@@ -289,8 +289,8 @@ export class SettingsEditor2 extends BaseEditor {
const
reportModifiedProps
=
{
key
,
query
:
this
.
searchWidget
.
getValue
(),
searchResults
:
this
.
searchResultModel
.
getUniqueResults
(),
rawResults
:
this
.
searchResultModel
.
getRawResults
(),
searchResults
:
this
.
searchResultModel
&&
this
.
searchResultModel
.
getUniqueResults
(),
rawResults
:
this
.
searchResultModel
&&
this
.
searchResultModel
.
getRawResults
(),
showConfiguredOnly
:
this
.
showConfiguredSettingsOnly
,
isReset
:
typeof
value
===
'
undefined
'
,
settingsTarget
:
this
.
settingsTargetsWidget
.
settingsTarget
as
SettingsTarget
...
...
@@ -327,12 +327,14 @@ export class SettingsEditor2 extends BaseEditor {
localIndex
:
remoteResult
&&
(
arrays
.
firstIndex
(
remoteResult
.
filterMatches
,
m
=>
m
.
setting
.
key
===
props
.
key
)
+
localResult
.
filterMatches
.
length
);
if
(
this
.
searchResultModel
)
{
const
rawResults
=
this
.
searchResultModel
.
getRawResults
();
if
(
rawResults
[
SearchResultIdx
.
Remote
])
{
const
_nlpIndex
=
arrays
.
firstIndex
(
rawResults
[
SearchResultIdx
.
Remote
].
filterMatches
,
m
=>
m
.
setting
.
key
===
props
.
key
);
nlpIndex
=
_nlpIndex
>=
0
?
_nlpIndex
:
undefined
;
}
}
}
const
reportedTarget
=
props
.
settingsTarget
===
ConfigurationTarget
.
USER
?
'
user
'
:
props
.
settingsTarget
===
ConfigurationTarget
.
WORKSPACE
?
'
workspace
'
:
...
...
@@ -371,19 +373,18 @@ export class SettingsEditor2 extends BaseEditor {
this
.
defaultSettingsEditorModel
=
model
;
if
(
!
this
.
settingsTree
.
getInput
())
{
this
.
settingsTree
.
setInput
(
this
.
defaultSettingsEditorModel
);
const
commonlyUsedGroup
=
this
.
defaultSettingsEditorModel
.
settingsGroups
[
0
];
this
.
settingsTree
.
expand
(
this
.
treeDataSource
.
getGroupElement
(
commonlyUsedGroup
));
this
.
expandCommonlyUsedSettings
();
}
});
}
return
TPromise
.
as
(
null
);
}
private
onInputChanged
():
void
{
private
on
Search
InputChanged
():
void
{
const
query
=
this
.
searchWidget
.
getValue
().
trim
();
this
.
delayedFilterLogging
.
cancel
();
this
.
triggerSearch
(
query
).
then
(()
=>
{
if
(
query
&&
this
.
searchResultModel
.
hasResults
()
)
{
if
(
query
&&
this
.
searchResultModel
)
{
this
.
delayedFilterLogging
.
trigger
(()
=>
this
.
reportFilteringUsed
(
query
,
this
.
searchResultModel
.
getUniqueResults
()));
}
});
...
...
@@ -394,18 +395,27 @@ export class SettingsEditor2 extends BaseEditor {
return
TPromise
.
join
([
this
.
localSearchDelayer
.
trigger
(()
=>
this
.
localFilterPreferences
(
query
)),
this
.
remoteSearchThrottle
.
trigger
(()
=>
this
.
remoteSearchPreferences
(
query
),
500
)
])
as
TPromise
;
]).
then
(()
=>
{
this
.
settingsTree
.
setInput
(
this
.
searchResultModel
.
resultsAsGroup
());
});
}
else
{
// When clearing the input, update immediately to clear it
this
.
localSearchDelayer
.
cancel
();
this
.
remoteSearchThrottle
.
cancel
();
this
.
searchResultModel
.
clear
();
// this.renderEntries();
this
.
searchResultModel
=
null
;
this
.
settingsTree
.
setInput
(
this
.
defaultSettingsEditorModel
);
this
.
expandCommonlyUsedSettings
();
return
TPromise
.
wrap
(
null
);
}
}
private
expandCommonlyUsedSettings
():
void
{
const
commonlyUsedGroup
=
this
.
defaultSettingsEditorModel
.
settingsGroups
[
0
];
this
.
settingsTree
.
expand
(
this
.
treeDataSource
.
getGroupElement
(
commonlyUsedGroup
));
}
private
reportFilteringUsed
(
query
:
string
,
results
:
ISearchResult
[]):
void
{
const
nlpResult
=
results
[
SearchResultIdx
.
Remote
];
const
nlpMetadata
=
nlpResult
&&
nlpResult
.
metadata
;
...
...
@@ -486,33 +496,6 @@ export class SettingsEditor2 extends BaseEditor {
});
}
// private getEntriesFromSearch(searchResults: ISearchResult[]): ListEntry[] {
// const entries: ISettingItemEntry[] = [];
// const seenSettings = new Set<string>();
// const focusedElement = this.settingsList.getFocusedElements()[0];
// const focusedId = focusedElement && focusedElement.id;
// for (let result of searchResults) {
// if (!result) {
// continue;
// }
// for (let match of result.filterMatches) {
// if (!seenSettings.has(match.setting.key)) {
// const entry = this.settingToEntry(match.setting, 'search');
// entry.isFocused = entry.id === focusedId;
// if (!this.showConfiguredSettingsOnly || entry.isConfigured) {
// seenSettings.add(entry.key);
// entries.push(entry);
// }
// }
// }
// }
// return entries;
// }
private
layoutSettingsList
():
void
{
const
listHeight
=
this
.
dimension
.
height
-
(
DOM
.
getDomNodePagePosition
(
this
.
headerContainer
).
height
+
12
/*padding*/
);
this
.
settingsTreeContainer
.
style
.
height
=
`
${
listHeight
}
px`
;
...
...
@@ -607,18 +590,29 @@ class SearchResultModel {
return
this
.
rawSearchResults
;
}
hasResults
():
boolean
{
return
!!
this
.
rawSearchResults
;
}
clear
():
void
{
this
.
cachedUniqueSearchResults
=
null
;
this
.
rawSearchResults
=
null
;
}
setResult
(
type
:
SearchResultIdx
,
result
:
ISearchResult
):
void
{
this
.
cachedUniqueSearchResults
=
null
;
this
.
rawSearchResults
=
this
.
rawSearchResults
||
[];
this
.
rawSearchResults
[
type
]
=
result
;
}
resultsAsGroup
():
ISettingsGroup
{
const
flatSettings
:
ISetting
[]
=
[];
this
.
getUniqueResults
()
.
filter
(
r
=>
!!
r
)
.
forEach
(
r
=>
{
flatSettings
.
push
(
...
r
.
filterMatches
.
map
(
m
=>
m
.
setting
));
});
return
<
ISettingsGroup
>
{
id
:
'
settingsSearchResultGroup
'
,
range
:
null
,
sections
:
[
{
settings
:
flatSettings
}
],
title
:
'
searchResults
'
,
titleRange
:
null
};
}
}
src/vs/workbench/parts/preferences/browser/settingsTree.ts
浏览文件 @
1269a996
...
...
@@ -61,7 +61,7 @@ export interface IButtonElement extends ITreeItem {
}
export
type
TreeElement
=
ISettingElement
|
IGroupElement
|
IButtonElement
;
export
type
TreeElementOrRoot
=
TreeElement
|
DefaultSettingsEditorModel
;
export
type
TreeElementOrRoot
=
TreeElement
|
DefaultSettingsEditorModel
|
ISettingsGroup
;
export
class
SettingsDataSource
implements
IDataSource
{
constructor
(
...
...
@@ -69,7 +69,7 @@ export class SettingsDataSource implements IDataSource {
@
IConfigurationService
private
configurationService
:
IConfigurationService
)
{
}
public
getGroupElement
(
group
:
ISettingsGroup
):
IGroupElement
{
getGroupElement
(
group
:
ISettingsGroup
):
IGroupElement
{
return
<
IGroupElement
>
{
type
:
TreeItemType
.
groupTitle
,
group
,
...
...
@@ -77,7 +77,7 @@ export class SettingsDataSource implements IDataSource {
};
}
public
getSettingElement
(
setting
:
ISetting
,
group
:
ISettingsGroup
):
ISettingElement
{
getSettingElement
(
setting
:
ISetting
,
group
:
ISettingsGroup
):
ISettingElement
{
const
targetSelector
=
this
.
viewState
.
settingsTarget
===
ConfigurationTarget
.
USER
?
'
user
'
:
'
workspace
'
;
const
inspected
=
this
.
configurationService
.
inspect
(
setting
.
key
);
const
isConfigured
=
typeof
inspected
[
targetSelector
]
!==
'
undefined
'
;
...
...
@@ -110,11 +110,15 @@ export class SettingsDataSource implements IDataSource {
return
element
instanceof
DefaultSettingsEditorModel
?
'
root
'
:
element
.
id
;
}
hasChildren
(
tree
:
ITree
,
element
:
TreeElement
):
boolean
{
hasChildren
(
tree
:
ITree
,
element
:
TreeElement
OrRoot
):
boolean
{
if
(
element
instanceof
DefaultSettingsEditorModel
)
{
return
true
;
}
if
(
elementIsSettingsGroup
(
element
))
{
return
true
;
}
if
(
element
.
type
===
TreeItemType
.
groupTitle
)
{
return
true
;
}
...
...
@@ -122,24 +126,23 @@ export class SettingsDataSource implements IDataSource {
return
false
;
}
getChildren
(
tree
:
ITree
,
element
:
TreeElementOrRoot
):
TPromise
<
any
,
any
>
{
_getChildren
(
element
:
TreeElementOrRoot
):
TreeElement
[]
{
if
(
element
instanceof
DefaultSettingsEditorModel
)
{
return
TPromise
.
as
(
this
.
getRootChildren
(
element
));
return
this
.
getRootChildren
(
element
);
}
else
if
(
elementIsSettingsGroup
(
element
))
{
return
this
.
getGroupChildren
(
element
);
}
else
if
(
element
.
type
===
TreeItemType
.
groupTitle
)
{
const
entries
:
ISettingElement
[]
=
[];
for
(
const
section
of
element
.
group
.
sections
)
{
for
(
const
setting
of
section
.
settings
)
{
entries
.
push
(
this
.
getSettingElement
(
setting
,
element
.
group
));
}
}
return
TPromise
.
wrap
(
entries
);
return
this
.
getGroupChildren
(
element
.
group
);
}
else
{
// No children...
return
TPromise
.
wrap
(
null
)
;
return
null
;
}
}
getChildren
(
tree
:
ITree
,
element
:
TreeElementOrRoot
):
TPromise
<
any
,
any
>
{
return
TPromise
.
as
(
this
.
_getChildren
(
element
));
}
private
getRootChildren
(
root
:
DefaultSettingsEditorModel
):
TreeElement
[]
{
const
groupItems
:
TreeElement
[]
=
root
.
settingsGroups
.
map
(
g
=>
this
.
getGroupElement
(
g
));
...
...
@@ -153,6 +156,17 @@ export class SettingsDataSource implements IDataSource {
return
groupItems
;
}
private
getGroupChildren
(
group
:
ISettingsGroup
):
ISettingElement
[]
{
const
entries
:
ISettingElement
[]
=
[];
for
(
const
section
of
group
.
sections
)
{
for
(
const
setting
of
section
.
settings
)
{
entries
.
push
(
this
.
getSettingElement
(
setting
,
group
));
}
}
return
entries
;
}
getParent
(
tree
:
ITree
,
element
:
TreeElement
):
TPromise
<
any
,
any
>
{
if
(
!
(
element
instanceof
DefaultSettingsEditorModel
))
{
return
TPromise
.
wrap
(
element
.
parent
);
...
...
@@ -162,6 +176,10 @@ export class SettingsDataSource implements IDataSource {
}
}
function
elementIsSettingsGroup
(
element
:
TreeElementOrRoot
):
element
is
ISettingsGroup
{
return
!!
(
<
ISettingsGroup
>
element
).
sections
;
}
export
interface
ISettingsEditorViewState
{
settingsTarget
:
SettingsTarget
;
showConfiguredOnly
?:
boolean
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录