Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0d438de5
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,发现更多精彩内容 >>
提交
0d438de5
编写于
11月 14, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #38329
上级
2393d4e3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
105 deletion
+63
-105
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
.../workbench/parts/preferences/browser/preferencesEditor.ts
+0
-72
src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts
...rkbench/parts/preferences/browser/preferencesRenderers.ts
+10
-12
src/vs/workbench/parts/preferences/browser/preferencesService.ts
...workbench/parts/preferences/browser/preferencesService.ts
+32
-17
src/vs/workbench/parts/preferences/common/preferencesModels.ts
...s/workbench/parts/preferences/common/preferencesModels.ts
+21
-4
未找到文件。
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
浏览文件 @
0d438de5
...
@@ -44,7 +44,6 @@ import { Widget } from 'vs/base/browser/ui/widget';
...
@@ -44,7 +44,6 @@ import { Widget } from 'vs/base/browser/ui/widget';
import
{
IPreferencesRenderer
,
DefaultSettingsRenderer
,
UserSettingsRenderer
,
WorkspaceSettingsRenderer
,
FolderSettingsRenderer
}
from
'
vs/workbench/parts/preferences/browser/preferencesRenderers
'
;
import
{
IPreferencesRenderer
,
DefaultSettingsRenderer
,
UserSettingsRenderer
,
WorkspaceSettingsRenderer
,
FolderSettingsRenderer
}
from
'
vs/workbench/parts/preferences/browser/preferencesRenderers
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
getCodeEditor
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
IEditorRegistry
,
Extensions
as
EditorExtensions
}
from
'
vs/workbench/browser/editor
'
;
import
{
IEditorRegistry
,
Extensions
as
EditorExtensions
}
from
'
vs/workbench/browser/editor
'
;
import
{
FoldingController
}
from
'
vs/editor/contrib/folding/folding
'
;
import
{
FoldingController
}
from
'
vs/editor/contrib/folding/folding
'
;
import
{
FindController
}
from
'
vs/editor/contrib/find/findController
'
;
import
{
FindController
}
from
'
vs/editor/contrib/find/findController
'
;
...
@@ -697,77 +696,6 @@ class SideBySidePreferencesWidget extends Widget {
...
@@ -697,77 +696,6 @@ class SideBySidePreferencesWidget extends Widget {
}
}
}
}
export
class
EditableSettingsEditor
extends
BaseTextEditor
{
public
static
ID
:
string
=
'
workbench.editor.settingsEditor
'
;
private
modelDisposables
:
IDisposable
[]
=
[];
private
saveDelayer
:
Delayer
<
void
>
;
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IStorageService
storageService
:
IStorageService
,
@
ITextResourceConfigurationService
configurationService
:
ITextResourceConfigurationService
,
@
IThemeService
themeService
:
IThemeService
,
@
IPreferencesService
private
preferencesService
:
IPreferencesService
,
@
ITextFileService
textFileService
:
ITextFileService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
)
{
super
(
EditableSettingsEditor
.
ID
,
telemetryService
,
instantiationService
,
storageService
,
configurationService
,
themeService
,
textFileService
,
editorGroupService
);
this
.
_register
({
dispose
:
()
=>
dispose
(
this
.
modelDisposables
)
});
this
.
saveDelayer
=
new
Delayer
<
void
>
(
1000
);
}
protected
createEditor
(
parent
:
Builder
):
void
{
super
.
createEditor
(
parent
);
const
codeEditor
=
getCodeEditor
(
this
);
if
(
codeEditor
)
{
this
.
_register
(
codeEditor
.
onDidChangeModel
(()
=>
this
.
onDidModelChange
()));
}
}
protected
getAriaLabel
():
string
{
const
input
=
this
.
input
;
const
inputName
=
input
&&
input
.
getName
();
let
ariaLabel
:
string
;
if
(
inputName
)
{
ariaLabel
=
nls
.
localize
(
'
fileEditorWithInputAriaLabel
'
,
"
{0}. Text file editor.
"
,
inputName
);
}
else
{
ariaLabel
=
nls
.
localize
(
'
fileEditorAriaLabel
'
,
"
Text file editor.
"
);
}
return
ariaLabel
;
}
setInput
(
input
:
EditorInput
,
options
:
EditorOptions
):
TPromise
<
void
>
{
return
super
.
setInput
(
input
,
options
)
.
then
(()
=>
this
.
input
.
resolve
()
.
then
(
editorModel
=>
editorModel
.
load
())
.
then
(
editorModel
=>
this
.
getControl
().
setModel
((
<
ResourceEditorModel
>
editorModel
).
textEditorModel
)));
}
clearInput
():
void
{
this
.
modelDisposables
=
dispose
(
this
.
modelDisposables
);
super
.
clearInput
();
}
private
onDidModelChange
():
void
{
this
.
modelDisposables
=
dispose
(
this
.
modelDisposables
);
const
model
=
getCodeEditor
(
this
).
getModel
();
if
(
model
)
{
this
.
preferencesService
.
createPreferencesEditorModel
(
model
.
uri
)
.
then
(
preferencesEditorModel
=>
{
const
settingsEditorModel
=
<
SettingsEditorModel
>
preferencesEditorModel
;
this
.
modelDisposables
.
push
(
settingsEditorModel
);
this
.
modelDisposables
.
push
(
model
.
onDidChangeContent
(()
=>
this
.
saveDelayer
.
trigger
(()
=>
settingsEditorModel
.
save
())));
});
}
}
}
export
class
DefaultPreferencesEditor
extends
BaseTextEditor
{
export
class
DefaultPreferencesEditor
extends
BaseTextEditor
{
public
static
ID
:
string
=
'
workbench.editor.defaultPreferences
'
;
public
static
ID
:
string
=
'
workbench.editor.defaultPreferences
'
;
...
...
src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts
浏览文件 @
0d438de5
...
@@ -270,14 +270,12 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR
...
@@ -270,14 +270,12 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR
this
.
filteredMatchesRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
FilteredMatchesRenderer
,
editor
));
this
.
filteredMatchesRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
FilteredMatchesRenderer
,
editor
));
this
.
editSettingActionRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
EditSettingRenderer
,
editor
,
preferencesModel
,
this
.
settingHighlighter
));
this
.
editSettingActionRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
EditSettingRenderer
,
editor
,
preferencesModel
,
this
.
settingHighlighter
));
this
.
feedbackWidgetRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
FeedbackWidgetRenderer
,
editor
));
this
.
feedbackWidgetRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
FeedbackWidgetRenderer
,
editor
));
const
parenthesisHidingRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
StaticContentHidingRenderer
,
editor
,
preferencesModel
));
this
.
hiddenAreasRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
HiddenAreasRenderer
,
editor
,
[
this
.
settingsGroupTitleRenderer
,
this
.
filteredMatchesRenderer
,
parenthesisHidingRenderer
]));
this
.
_register
(
this
.
editSettingActionRenderer
.
onUpdateSetting
(
e
=>
this
.
_onUpdatePreference
.
fire
(
e
)));
this
.
_register
(
this
.
editSettingActionRenderer
.
onUpdateSetting
(
e
=>
this
.
_onUpdatePreference
.
fire
(
e
)));
const
parenthesisHidingRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
StaticContentHidingRenderer
,
editor
,
preferencesModel
.
settingsGroups
));
const
hiddenAreasProviders
=
[
this
.
settingsGroupTitleRenderer
,
this
.
filteredMatchesRenderer
,
parenthesisHidingRenderer
];
this
.
hiddenAreasRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
HiddenAreasRenderer
,
editor
,
hiddenAreasProviders
));
this
.
_register
(
this
.
settingsGroupTitleRenderer
.
onHiddenAreasChanged
(()
=>
this
.
hiddenAreasRenderer
.
render
()));
this
.
_register
(
this
.
settingsGroupTitleRenderer
.
onHiddenAreasChanged
(()
=>
this
.
hiddenAreasRenderer
.
render
()));
this
.
_register
(
preferencesModel
.
onDidChangeGroups
(()
=>
this
.
render
()));
this
.
onTriggeredFuzzy
=
this
.
settingsHeaderRenderer
.
onClick
;
this
.
onTriggeredFuzzy
=
this
.
settingsHeaderRenderer
.
onClick
;
}
}
...
@@ -295,7 +293,6 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR
...
@@ -295,7 +293,6 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR
this
.
settingsGroupTitleRenderer
.
render
(
this
.
preferencesModel
.
settingsGroups
);
this
.
settingsGroupTitleRenderer
.
render
(
this
.
preferencesModel
.
settingsGroups
);
this
.
editSettingActionRenderer
.
render
(
this
.
preferencesModel
.
settingsGroups
,
this
.
_associatedPreferencesModel
);
this
.
editSettingActionRenderer
.
render
(
this
.
preferencesModel
.
settingsGroups
,
this
.
_associatedPreferencesModel
);
this
.
feedbackWidgetRenderer
.
render
(
null
);
this
.
feedbackWidgetRenderer
.
render
(
null
);
this
.
hiddenAreasRenderer
.
render
();
this
.
settingHighlighter
.
clear
(
true
);
this
.
settingHighlighter
.
clear
(
true
);
this
.
settingsGroupTitleRenderer
.
showGroup
(
0
);
this
.
settingsGroupTitleRenderer
.
showGroup
(
0
);
this
.
hiddenAreasRenderer
.
render
();
this
.
hiddenAreasRenderer
.
render
();
...
@@ -379,7 +376,7 @@ export interface HiddenAreasProvider {
...
@@ -379,7 +376,7 @@ export interface HiddenAreasProvider {
export
class
StaticContentHidingRenderer
extends
Disposable
implements
HiddenAreasProvider
{
export
class
StaticContentHidingRenderer
extends
Disposable
implements
HiddenAreasProvider
{
constructor
(
private
editor
:
ICodeEditor
,
private
settings
Groups
:
ISettingsGroup
[]
constructor
(
private
editor
:
ICodeEditor
,
private
settings
EditorModel
:
ISettingsEditorModel
)
{
)
{
super
();
super
();
}
}
...
@@ -388,7 +385,8 @@ export class StaticContentHidingRenderer extends Disposable implements HiddenAre
...
@@ -388,7 +385,8 @@ export class StaticContentHidingRenderer extends Disposable implements HiddenAre
const
model
=
this
.
editor
.
getModel
();
const
model
=
this
.
editor
.
getModel
();
// Hide extra chars for "search results" and "commonly used" groups
// Hide extra chars for "search results" and "commonly used" groups
const
lastGroup
=
tail
(
this
.
settingsGroups
);
const
settingsGroups
=
this
.
settingsEditorModel
.
settingsGroups
;
const
lastGroup
=
tail
(
settingsGroups
);
return
[
return
[
{
{
startLineNumber
:
1
,
startLineNumber
:
1
,
...
@@ -397,10 +395,10 @@ export class StaticContentHidingRenderer extends Disposable implements HiddenAre
...
@@ -397,10 +395,10 @@ export class StaticContentHidingRenderer extends Disposable implements HiddenAre
endColumn
:
model
.
getLineMaxColumn
(
2
)
endColumn
:
model
.
getLineMaxColumn
(
2
)
},
},
{
{
startLineNumber
:
this
.
settingsGroups
[
0
].
range
.
endLineNumber
+
1
,
startLineNumber
:
settingsGroups
[
0
].
range
.
endLineNumber
+
1
,
startColumn
:
model
.
getLineMinColumn
(
this
.
settingsGroups
[
0
].
range
.
endLineNumber
+
1
),
startColumn
:
model
.
getLineMinColumn
(
settingsGroups
[
0
].
range
.
endLineNumber
+
1
),
endLineNumber
:
this
.
settingsGroups
[
0
].
range
.
endLineNumber
+
4
,
endLineNumber
:
settingsGroups
[
0
].
range
.
endLineNumber
+
4
,
endColumn
:
model
.
getLineMaxColumn
(
this
.
settingsGroups
[
0
].
range
.
endLineNumber
+
4
)
endColumn
:
model
.
getLineMaxColumn
(
settingsGroups
[
0
].
range
.
endLineNumber
+
4
)
},
},
{
{
startLineNumber
:
lastGroup
.
range
.
endLineNumber
+
1
,
startLineNumber
:
lastGroup
.
range
.
endLineNumber
+
1
,
...
...
src/vs/workbench/parts/preferences/browser/preferencesService.ts
浏览文件 @
0d438de5
...
@@ -21,11 +21,10 @@ import { IModel } from 'vs/editor/common/editorCommon';
...
@@ -21,11 +21,10 @@ import { IModel } from 'vs/editor/common/editorCommon';
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IFileService
,
FileOperationError
,
FileOperationResult
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileService
,
FileOperationError
,
FileOperationResult
}
from
'
vs/platform/files/common/files
'
;
import
{
IMessageService
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
IMessageService
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IPreferencesService
,
IPreferencesEditorModel
,
ISetting
,
getSettingsTargetName
,
FOLDER_SETTINGS_PATH
,
DEFAULT_SETTINGS_EDITOR_SETTING
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
IPreferencesService
,
IPreferencesEditorModel
,
ISetting
,
getSettingsTargetName
,
FOLDER_SETTINGS_PATH
,
DEFAULT_SETTINGS_EDITOR_SETTING
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
SettingsEditorModel
,
DefaultSettingsEditorModel
,
DefaultKeybindingsEditorModel
,
defaultKeybindingsContents
,
DefaultSettings
Model
,
WorkspaceConfigurationEditorModel
}
from
'
vs/workbench/parts/preferences/common/preferencesModels
'
;
import
{
SettingsEditorModel
,
DefaultSettingsEditorModel
,
DefaultKeybindingsEditorModel
,
defaultKeybindingsContents
,
DefaultSettings
,
WorkspaceConfigurationEditorModel
}
from
'
vs/workbench/parts/preferences/common/preferencesModels
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
DefaultPreferencesEditorInput
,
PreferencesEditorInput
}
from
'
vs/workbench/parts/preferences/browser/preferencesEditor
'
;
import
{
DefaultPreferencesEditorInput
,
PreferencesEditorInput
}
from
'
vs/workbench/parts/preferences/browser/preferencesEditor
'
;
import
{
KeybindingsEditorInput
}
from
'
vs/workbench/parts/preferences/browser/keybindingsEditor
'
;
import
{
KeybindingsEditorInput
}
from
'
vs/workbench/parts/preferences/browser/keybindingsEditor
'
;
...
@@ -53,9 +52,9 @@ export class PreferencesService extends Disposable implements IPreferencesServic
...
@@ -53,9 +52,9 @@ export class PreferencesService extends Disposable implements IPreferencesServic
private
_onDispose
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
private
_onDispose
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
private
_defaultSettingsUriCounter
=
0
;
private
_defaultSettingsUriCounter
=
0
;
private
_defaultSettingsContentModel
:
DefaultSettings
Model
;
private
_defaultSettingsContentModel
:
DefaultSettings
;
private
_defaultResourceSettingsUriCounter
=
0
;
private
_defaultResourceSettingsUriCounter
=
0
;
private
_defaultResourceSettingsContentModel
:
DefaultSettings
Model
;
private
_defaultResourceSettingsContentModel
:
DefaultSettings
;
constructor
(
constructor
(
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
...
@@ -68,7 +67,6 @@ export class PreferencesService extends Disposable implements IPreferencesServic
...
@@ -68,7 +67,6 @@ export class PreferencesService extends Disposable implements IPreferencesServic
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
ITextModelService
private
textModelResolverService
:
ITextModelService
,
@
ITextModelService
private
textModelResolverService
:
ITextModelService
,
@
IExtensionService
private
extensionService
:
IExtensionService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IModelService
private
modelService
:
IModelService
,
@
IModelService
private
modelService
:
IModelService
,
@
IJSONEditingService
private
jsonEditingService
:
IJSONEditingService
,
@
IJSONEditingService
private
jsonEditingService
:
IJSONEditingService
,
...
@@ -110,14 +108,31 @@ export class PreferencesService extends Disposable implements IPreferencesServic
...
@@ -110,14 +108,31 @@ export class PreferencesService extends Disposable implements IPreferencesServic
resolveModel
(
uri
:
URI
):
TPromise
<
IModel
>
{
resolveModel
(
uri
:
URI
):
TPromise
<
IModel
>
{
if
(
this
.
isDefaultSettingsResource
(
uri
)
||
this
.
isDefaultResourceSettingsResource
(
uri
))
{
if
(
this
.
isDefaultSettingsResource
(
uri
)
||
this
.
isDefaultResourceSettingsResource
(
uri
))
{
return
this
.
extensionService
.
onReady
()
.
then
(()
=>
{
const
scope
=
this
.
isDefaultSettingsResource
(
uri
)
?
ConfigurationScope
.
WINDOW
:
ConfigurationScope
.
RESOURCE
;
const
scope
=
this
.
isDefaultSettingsResource
(
uri
)
?
ConfigurationScope
.
WINDOW
:
ConfigurationScope
.
RESOURCE
;
const
mode
=
this
.
modeService
.
getOrCreateMode
(
'
json
'
);
const
settingsModel
=
this
.
getDefaultSettingsModel
(
scope
);
const
model
=
this
.
_register
(
this
.
modelService
.
createModel
(
''
,
mode
,
uri
));
const
mode
=
this
.
modeService
.
getOrCreateMode
(
'
json
'
);
const
model
=
this
.
_register
(
this
.
modelService
.
createModel
(
settingsModel
.
content
,
mode
,
uri
));
let
defaultSettings
:
DefaultSettings
;
return
model
;
this
.
configurationService
.
onDidChangeConfiguration
(
e
=>
{
});
if
(
e
.
source
===
ConfigurationTarget
.
DEFAULT
)
{
const
model
=
this
.
modelService
.
getModel
(
uri
);
if
(
!
model
)
{
// model has not been given out => nothing to do
return
;
}
defaultSettings
=
this
.
getDefaultSettings
(
scope
);
this
.
modelService
.
updateModel
(
model
,
defaultSettings
.
parse
());
}
});
// Check if Default settings is already created and updated in above promise
if
(
!
defaultSettings
)
{
defaultSettings
=
this
.
getDefaultSettings
(
scope
);
this
.
modelService
.
updateModel
(
model
,
defaultSettings
.
parse
());
}
return
TPromise
.
as
(
model
);
}
}
if
(
this
.
defaultKeybindingsResource
.
toString
()
===
uri
.
toString
())
{
if
(
this
.
defaultKeybindingsResource
.
toString
()
===
uri
.
toString
())
{
...
@@ -288,20 +303,20 @@ export class PreferencesService extends Disposable implements IPreferencesServic
...
@@ -288,20 +303,20 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return
this
.
textModelResolverService
.
createModelReference
(
defaultSettingsUri
)
return
this
.
textModelResolverService
.
createModelReference
(
defaultSettingsUri
)
.
then
(
reference
=>
{
.
then
(
reference
=>
{
const
scope
=
this
.
isDefaultSettingsResource
(
defaultSettingsUri
)
?
ConfigurationScope
.
WINDOW
:
ConfigurationScope
.
RESOURCE
;
const
scope
=
this
.
isDefaultSettingsResource
(
defaultSettingsUri
)
?
ConfigurationScope
.
WINDOW
:
ConfigurationScope
.
RESOURCE
;
return
this
.
instantiationService
.
createInstance
(
DefaultSettingsEditorModel
,
defaultSettingsUri
,
reference
,
scope
,
this
.
getDefaultSettings
Model
(
scope
).
settingsGroups
);
return
this
.
instantiationService
.
createInstance
(
DefaultSettingsEditorModel
,
defaultSettingsUri
,
reference
,
scope
,
this
.
getDefaultSettings
(
scope
)
);
});
});
}
}
private
getDefaultSettings
Model
(
scope
:
ConfigurationScope
):
DefaultSettingsModel
{
private
getDefaultSettings
(
scope
:
ConfigurationScope
):
DefaultSettings
{
switch
(
scope
)
{
switch
(
scope
)
{
case
ConfigurationScope
.
WINDOW
:
case
ConfigurationScope
.
WINDOW
:
if
(
!
this
.
_defaultSettingsContentModel
)
{
if
(
!
this
.
_defaultSettingsContentModel
)
{
this
.
_defaultSettingsContentModel
=
new
DefaultSettings
Model
(
this
.
getMostCommonlyUsedSettings
(),
scope
);
this
.
_defaultSettingsContentModel
=
new
DefaultSettings
(
this
.
getMostCommonlyUsedSettings
(),
scope
);
}
}
return
this
.
_defaultSettingsContentModel
;
return
this
.
_defaultSettingsContentModel
;
case
ConfigurationScope
.
RESOURCE
:
case
ConfigurationScope
.
RESOURCE
:
if
(
!
this
.
_defaultResourceSettingsContentModel
)
{
if
(
!
this
.
_defaultResourceSettingsContentModel
)
{
this
.
_defaultResourceSettingsContentModel
=
new
DefaultSettings
Model
(
this
.
getMostCommonlyUsedSettings
(),
scope
);
this
.
_defaultResourceSettingsContentModel
=
new
DefaultSettings
(
this
.
getMostCommonlyUsedSettings
(),
scope
);
}
}
return
this
.
_defaultResourceSettingsContentModel
;
return
this
.
_defaultResourceSettingsContentModel
;
}
}
...
...
src/vs/workbench/parts/preferences/common/preferencesModels.ts
浏览文件 @
0d438de5
...
@@ -8,7 +8,7 @@ import { assign } from 'vs/base/common/objects';
...
@@ -8,7 +8,7 @@ import { assign } from 'vs/base/common/objects';
import
{
tail
}
from
'
vs/base/common/arrays
'
;
import
{
tail
}
from
'
vs/base/common/arrays
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
IReference
}
from
'
vs/base/common/lifecycle
'
;
import
{
IReference
}
from
'
vs/base/common/lifecycle
'
;
import
Event
from
'
vs/base/common/event
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
visit
,
JSONVisitor
}
from
'
vs/base/common/json
'
;
import
{
visit
,
JSONVisitor
}
from
'
vs/base/common/json
'
;
import
{
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IModel
}
from
'
vs/editor/common/editorCommon
'
;
...
@@ -499,7 +499,8 @@ export class WorkspaceConfigModel extends SettingsEditorModel implements ISettin
...
@@ -499,7 +499,8 @@ export class WorkspaceConfigModel extends SettingsEditorModel implements ISettin
}
}
}
}
export
class
DefaultSettingsModel
{
export
class
DefaultSettings
{
private
_allSettingsGroups
:
ISettingsGroup
[];
private
_allSettingsGroups
:
ISettingsGroup
[];
private
_content
:
string
;
private
_content
:
string
;
...
@@ -525,13 +526,14 @@ export class DefaultSettingsModel {
...
@@ -525,13 +526,14 @@ export class DefaultSettingsModel {
return
this
.
_allSettingsGroups
;
return
this
.
_allSettingsGroups
;
}
}
p
rivate
parse
()
{
p
arse
():
string
{
const
configurations
=
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
getConfigurations
().
slice
();
const
configurations
=
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
getConfigurations
().
slice
();
const
settingsGroups
=
this
.
removeEmptySettingsGroups
(
configurations
.
sort
(
this
.
compareConfigurationNodes
).
reduce
((
result
,
config
,
index
,
array
)
=>
this
.
parseConfig
(
config
,
result
,
array
),
[]));
const
settingsGroups
=
this
.
removeEmptySettingsGroups
(
configurations
.
sort
(
this
.
compareConfigurationNodes
).
reduce
((
result
,
config
,
index
,
array
)
=>
this
.
parseConfig
(
config
,
result
,
array
),
[]));
this
.
initAllSettingsMap
(
settingsGroups
);
this
.
initAllSettingsMap
(
settingsGroups
);
const
mostCommonlyUsed
=
this
.
getMostCommonlyUsedSettings
(
settingsGroups
);
const
mostCommonlyUsed
=
this
.
getMostCommonlyUsedSettings
(
settingsGroups
);
this
.
_allSettingsGroups
=
[
mostCommonlyUsed
,
...
settingsGroups
];
this
.
_allSettingsGroups
=
[
mostCommonlyUsed
,
...
settingsGroups
];
this
.
_content
=
this
.
toContent
(
mostCommonlyUsed
,
settingsGroups
);
this
.
_content
=
this
.
toContent
(
mostCommonlyUsed
,
settingsGroups
);
return
this
.
_content
;
}
}
private
initAllSettingsMap
(
allSettingsGroups
:
ISettingsGroup
[]):
void
{
private
initAllSettingsMap
(
allSettingsGroups
:
ISettingsGroup
[]):
void
{
...
@@ -678,15 +680,26 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
...
@@ -678,15 +680,26 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
private
_settingsByName
:
Map
<
string
,
ISetting
>
;
private
_settingsByName
:
Map
<
string
,
ISetting
>
;
private
_mostRelevantLineOffset
:
number
;
private
_mostRelevantLineOffset
:
number
;
private
_settingsGroups
:
ISettingsGroup
[];
private
_onDidChangeGroups
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChangeGroups
:
Event
<
void
>
=
this
.
_onDidChangeGroups
.
event
;
constructor
(
constructor
(
private
_uri
:
URI
,
private
_uri
:
URI
,
reference
:
IReference
<
ITextEditorModel
>
,
reference
:
IReference
<
ITextEditorModel
>
,
readonly
configurationScope
:
ConfigurationScope
,
readonly
configurationScope
:
ConfigurationScope
,
readonly
settingsGroups
:
ISettingsGroup
[]
defaultSettings
:
DefaultSettings
)
{
)
{
super
();
super
();
this
.
_settingsGroups
=
defaultSettings
.
settingsGroups
;
this
.
_model
=
reference
.
object
.
textEditorModel
;
this
.
_model
=
reference
.
object
.
textEditorModel
;
this
.
_register
(
this
.
onDispose
(()
=>
reference
.
dispose
()));
this
.
_register
(
this
.
onDispose
(()
=>
reference
.
dispose
()));
this
.
_register
(
this
.
_model
.
onDidChangeContent
(()
=>
{
this
.
_settingsGroups
=
defaultSettings
.
settingsGroups
;
this
.
_onDidChangeGroups
.
fire
();
}));
this
.
initAllSettingsMap
();
this
.
initAllSettingsMap
();
this
.
_mostRelevantLineOffset
=
tail
(
this
.
settingsGroups
).
range
.
endLineNumber
+
2
;
this
.
_mostRelevantLineOffset
=
tail
(
this
.
settingsGroups
).
range
.
endLineNumber
+
2
;
...
@@ -696,6 +709,10 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
...
@@ -696,6 +709,10 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
return
this
.
_uri
;
return
this
.
_uri
;
}
}
public
get
settingsGroups
():
ISettingsGroup
[]
{
return
this
.
_settingsGroups
;
}
public
filterSettings
(
filter
:
string
,
groupFilter
:
IGroupFilter
,
settingFilter
:
ISettingFilter
,
mostRelevantSettings
?:
string
[]):
IFilterResult
{
public
filterSettings
(
filter
:
string
,
groupFilter
:
IGroupFilter
,
settingFilter
:
ISettingFilter
,
mostRelevantSettings
?:
string
[]):
IFilterResult
{
if
(
mostRelevantSettings
)
{
if
(
mostRelevantSettings
)
{
const
mostRelevantGroup
=
this
.
renderMostRelevantSettings
(
mostRelevantSettings
);
const
mostRelevantGroup
=
this
.
renderMostRelevantSettings
(
mostRelevantSettings
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录