Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cb5558b9
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,发现更多精彩内容 >>
提交
cb5558b9
编写于
8月 15, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #50641 - handle different settings scopes correctly in UI
上级
22ab03e7
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
135 addition
and
79 deletion
+135
-79
src/vs/workbench/parts/preferences/browser/preferencesActions.ts
...workbench/parts/preferences/browser/preferencesActions.ts
+17
-22
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
.../workbench/parts/preferences/browser/preferencesEditor.ts
+4
-4
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
...vs/workbench/parts/preferences/browser/settingsEditor2.ts
+19
-13
src/vs/workbench/parts/preferences/common/preferencesContribution.ts
...bench/parts/preferences/common/preferencesContribution.ts
+3
-3
src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts
.../preferences/electron-browser/preferences.contribution.ts
+9
-3
src/vs/workbench/services/preferences/browser/preferencesService.ts
...kbench/services/preferences/browser/preferencesService.ts
+73
-10
src/vs/workbench/services/preferences/common/preferences.ts
src/vs/workbench/services/preferences/common/preferences.ts
+5
-6
src/vs/workbench/services/preferences/common/preferencesEditorInput.ts
...nch/services/preferences/common/preferencesEditorInput.ts
+5
-18
未找到文件。
src/vs/workbench/parts/preferences/browser/preferencesActions.ts
浏览文件 @
cb5558b9
...
...
@@ -45,13 +45,13 @@ export class OpenSettings2Action extends Action {
constructor
(
id
:
string
,
label
:
string
,
@
IPreferencesService
private
preferencesService
2
:
IPreferencesService
@
IPreferencesService
private
preferencesService
:
IPreferencesService
)
{
super
(
id
,
label
);
}
public
run
(
event
?:
any
):
TPromise
<
any
>
{
return
this
.
preferencesService
2
.
openSettings2
(
);
return
this
.
preferencesService
.
openSettings
(
false
);
}
}
...
...
@@ -71,9 +71,8 @@ export class OpenSettingsAction extends Action {
}
public
run
(
event
?:
any
):
TPromise
<
any
>
{
return
this
.
configurationService
.
getValue
(
'
workbench.settings.editor
'
)
===
'
json
'
?
this
.
preferencesService
.
openSettings
()
:
this
.
preferencesService
.
openSettings2
();
const
jsonEditorPreferred
=
this
.
configurationService
.
getValue
(
'
workbench.settings.editor
'
)
===
'
json
'
;
return
this
.
preferencesService
.
openSettings
(
jsonEditorPreferred
);
}
}
...
...
@@ -110,9 +109,8 @@ export class OpenGlobalSettingsAction extends Action {
}
public
run
(
event
?:
any
):
TPromise
<
any
>
{
return
this
.
configurationService
.
getValue
(
'
workbench.settings.editor
'
)
===
'
json
'
?
this
.
preferencesService
.
openGlobalSettings
()
:
this
.
preferencesService
.
openSettings2
();
const
jsonEditorPreferred
=
this
.
configurationService
.
getValue
(
'
workbench.settings.editor
'
)
===
'
json
'
;
return
this
.
preferencesService
.
openGlobalSettings
(
jsonEditorPreferred
);
}
}
...
...
@@ -194,9 +192,8 @@ export class OpenWorkspaceSettingsAction extends Action {
}
public
run
(
event
?:
any
):
TPromise
<
any
>
{
return
this
.
configurationService
.
getValue
(
'
workbench.settings.editor
'
)
===
'
json
'
?
this
.
preferencesService
.
openWorkspaceSettings
()
:
this
.
preferencesService
.
openSettings2
();
const
jsonEditorPreferred
=
this
.
configurationService
.
getValue
(
'
workbench.settings.editor
'
)
===
'
json
'
;
return
this
.
preferencesService
.
openWorkspaceSettings
(
jsonEditorPreferred
);
}
public
dispose
():
void
{
...
...
@@ -234,17 +231,15 @@ export class OpenFolderSettingsAction extends Action {
}
public
run
():
TPromise
<
any
>
{
if
(
this
.
configurationService
.
getValue
(
'
workbench.settings.editor
'
)
===
'
json
'
)
{
return
this
.
commandService
.
executeCommand
<
IWorkspaceFolder
>
(
PICK_WORKSPACE_FOLDER_COMMAND_ID
)
.
then
(
workspaceFolder
=>
{
if
(
workspaceFolder
)
{
return
this
.
commandService
.
executeCommand
(
OPEN_FOLDER_SETTINGS_COMMAND
,
workspaceFolder
.
uri
);
}
return
null
;
});
}
else
{
return
this
.
preferencesService
.
openSettings2
();
}
return
this
.
commandService
.
executeCommand
<
IWorkspaceFolder
>
(
PICK_WORKSPACE_FOLDER_COMMAND_ID
)
.
then
(
workspaceFolder
=>
{
if
(
workspaceFolder
)
{
const
jsonEditorPreferred
=
this
.
configurationService
.
getValue
(
'
workbench.settings.editor
'
)
===
'
json
'
;
return
this
.
preferencesService
.
openFolderSettings
(
workspaceFolder
.
uri
,
jsonEditorPreferred
);
}
return
null
;
});
}
public
dispose
():
void
{
...
...
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
浏览文件 @
cb5558b9
...
...
@@ -120,7 +120,7 @@ export class PreferencesEditor extends BaseEditor {
});
openSettings2Button
.
label
=
nls
.
localize
(
'
openSettings2Label
'
,
"
new settings editor
"
);
openSettings2Button
.
element
.
classList
.
add
(
'
open-settings2-button
'
);
this
.
_register
(
openSettings2Button
.
onDidClick
(()
=>
this
.
preferencesService
.
openSettings
2
(
)));
this
.
_register
(
openSettings2Button
.
onDidClick
(()
=>
this
.
preferencesService
.
openSettings
(
false
)));
this
.
searchWidget
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
SearchWidget
,
this
.
headerContainer
,
{
ariaLabel
:
nls
.
localize
(
'
SearchSettingsWidget.AriaLabel
'
,
"
Search settings
"
),
...
...
@@ -263,11 +263,11 @@ export class PreferencesEditor extends BaseEditor {
const
promise
=
this
.
input
&&
this
.
input
.
isDirty
()
?
this
.
input
.
save
()
:
TPromise
.
as
(
true
);
promise
.
done
(
value
=>
{
if
(
target
===
ConfigurationTarget
.
USER
)
{
this
.
preferencesService
.
switchSettings
(
ConfigurationTarget
.
USER
,
this
.
preferencesService
.
userSettingsResource
);
this
.
preferencesService
.
switchSettings
(
ConfigurationTarget
.
USER
,
this
.
preferencesService
.
userSettingsResource
,
true
);
}
else
if
(
target
===
ConfigurationTarget
.
WORKSPACE
)
{
this
.
preferencesService
.
switchSettings
(
ConfigurationTarget
.
WORKSPACE
,
this
.
preferencesService
.
workspaceSettingsResource
);
this
.
preferencesService
.
switchSettings
(
ConfigurationTarget
.
WORKSPACE
,
this
.
preferencesService
.
workspaceSettingsResource
,
true
);
}
else
if
(
target
instanceof
URI
)
{
this
.
preferencesService
.
switchSettings
(
ConfigurationTarget
.
WORKSPACE_FOLDER
,
target
);
this
.
preferencesService
.
switchSettings
(
ConfigurationTarget
.
WORKSPACE_FOLDER
,
target
,
true
);
}
});
}
...
...
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
浏览文件 @
cb5558b9
...
...
@@ -43,6 +43,7 @@ import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsSer
import
{
IPreferencesService
,
ISearchResult
,
ISettingsEditorModel
}
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
{
ResourceEditorModel
}
from
'
vs/workbench/common/editor/resourceEditorModel
'
;
const
$
=
DOM
.
$
;
...
...
@@ -228,12 +229,15 @@ export class SettingsEditor2 extends BaseEditor {
const
targetWidgetContainer
=
DOM
.
append
(
headerControlsContainer
,
$
(
'
.settings-target-container
'
));
this
.
settingsTargetsWidget
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
SettingsTargetsWidget
,
targetWidgetContainer
));
this
.
settingsTargetsWidget
.
settingsTarget
=
ConfigurationTarget
.
USER
;
this
.
settingsTargetsWidget
.
onDidTargetChange
(()
=>
{
this
.
viewState
.
settingsTarget
=
this
.
settingsTargetsWidget
.
settingsTarget
;
this
.
toolbar
.
context
=
<
ISettingsToolbarContext
>
{
target
:
this
.
settingsTargetsWidget
.
settingsTarget
};
this
.
settingsTreeModel
.
update
();
this
.
renderTree
();
this
.
settingsTargetsWidget
.
onDidTargetChange
(
target
=>
{
this
.
viewState
.
settingsTarget
=
target
;
if
(
target
===
ConfigurationTarget
.
USER
)
{
this
.
preferencesService
.
openGlobalSettings
();
}
else
if
(
target
===
ConfigurationTarget
.
WORKSPACE
)
{
this
.
preferencesService
.
switchSettings
(
ConfigurationTarget
.
WORKSPACE
,
this
.
preferencesService
.
workspaceSettingsResource
);
}
else
if
(
target
instanceof
URI
)
{
this
.
preferencesService
.
switchSettings
(
ConfigurationTarget
.
WORKSPACE_FOLDER
,
target
);
}
});
this
.
createHeaderControls
(
headerControlsContainer
);
...
...
@@ -480,7 +484,7 @@ export class SettingsEditor2 extends BaseEditor {
// Force a render afterwards because onDidConfigurationUpdate doesn't fire if the update doesn't result in an effective setting value change
const
settingsTarget
=
this
.
settingsTargetsWidget
.
settingsTarget
;
const
resource
=
URI
.
isUri
(
settingsTarget
)
?
settingsTarget
:
undefined
;
const
configurationTarget
=
<
ConfigurationTarget
>
(
resource
?
undefined
:
settingsTarget
);
const
configurationTarget
=
<
ConfigurationTarget
>
(
resource
?
ConfigurationTarget
.
WORKSPACE_FOLDER
:
settingsTarget
);
const
overrides
:
IConfigurationOverrides
=
{
resource
};
// If the user is changing the value back to the default, do a 'reset' instead
...
...
@@ -567,13 +571,15 @@ export class SettingsEditor2 extends BaseEditor {
private
render
(
token
:
CancellationToken
):
TPromise
<
any
>
{
if
(
this
.
input
)
{
return
this
.
input
.
resolve
()
.
then
(
(
model
:
DefaultSettingsEditorModel
)
=>
{
.
then
(
model
=>
{
if
(
token
.
isCancellationRequested
)
{
return
void
0
;
}
this
.
_register
(
model
.
onDidChangeGroups
(()
=>
this
.
onConfigUpdate
()));
this
.
defaultSettingsEditorModel
=
model
;
return
this
.
preferencesService
.
createPreferencesEditorModel
((
<
ResourceEditorModel
>
model
).
textEditorModel
.
uri
);
}).
then
((
defaultSettingsEditorModel
:
DefaultSettingsEditorModel
)
=>
{
this
.
_register
(
defaultSettingsEditorModel
.
onDidChangeGroups
(()
=>
this
.
onConfigUpdate
()));
this
.
defaultSettingsEditorModel
=
defaultSettingsEditorModel
;
return
this
.
onConfigUpdate
();
});
}
...
...
@@ -945,11 +951,11 @@ class OpenSettingsAction extends Action {
private
_run
(
context
?:
ISettingsToolbarContext
):
TPromise
<
any
>
{
const
target
=
context
&&
context
.
target
;
if
(
target
===
ConfigurationTarget
.
USER
)
{
return
this
.
preferencesService
.
openGlobalSettings
();
return
this
.
preferencesService
.
openGlobalSettings
(
true
);
}
else
if
(
target
===
ConfigurationTarget
.
WORKSPACE
)
{
return
this
.
preferencesService
.
openWorkspaceSettings
();
return
this
.
preferencesService
.
openWorkspaceSettings
(
true
);
}
else
if
(
URI
.
isUri
(
target
))
{
return
this
.
preferencesService
.
openFolderSettings
(
target
);
return
this
.
preferencesService
.
openFolderSettings
(
target
,
true
);
}
return
TPromise
.
wrap
(
null
);
...
...
src/vs/workbench/parts/preferences/common/preferencesContribution.ts
浏览文件 @
cb5558b9
...
...
@@ -82,7 +82,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
// Global User Settings File
if
(
isEqual
(
resource
,
URI
.
file
(
this
.
environmentService
.
appSettingsPath
),
!
isLinux
))
{
return
{
override
:
this
.
preferencesService
.
openGlobalSettings
(
options
,
group
)
};
return
{
override
:
this
.
preferencesService
.
openGlobalSettings
(
true
,
options
,
group
)
};
}
// Single Folder Workspace Settings File
...
...
@@ -90,7 +90,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
if
(
state
===
WorkbenchState
.
FOLDER
)
{
const
folders
=
this
.
workspaceService
.
getWorkspace
().
folders
;
if
(
isEqual
(
resource
,
folders
[
0
].
toResource
(
FOLDER_SETTINGS_PATH
),
hasToIgnoreCase
(
resource
)))
{
return
{
override
:
this
.
preferencesService
.
openWorkspaceSettings
(
options
,
group
)
};
return
{
override
:
this
.
preferencesService
.
openWorkspaceSettings
(
true
,
options
,
group
)
};
}
}
...
...
@@ -99,7 +99,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
const
folders
=
this
.
workspaceService
.
getWorkspace
().
folders
;
for
(
let
i
=
0
;
i
<
folders
.
length
;
i
++
)
{
if
(
isEqual
(
resource
,
folders
[
i
].
toResource
(
FOLDER_SETTINGS_PATH
),
hasToIgnoreCase
(
resource
)))
{
return
{
override
:
this
.
preferencesService
.
openFolderSettings
(
folders
[
i
].
uri
,
options
,
group
)
};
return
{
override
:
this
.
preferencesService
.
openFolderSettings
(
folders
[
i
].
uri
,
true
,
options
,
group
)
};
}
}
}
...
...
src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts
浏览文件 @
cb5558b9
...
...
@@ -152,11 +152,17 @@ class KeybindingsEditorInputFactory implements IEditorInputFactory {
class
SettingsEditor2InputFactory
implements
IEditorInputFactory
{
public
serialize
(
editorInput
:
SettingsEditor2Input
):
string
{
return
JSON
.
stringify
({});
const
input
=
<
DefaultPreferencesEditorInput
>
editorInput
;
const
serialized
:
ISerializedDefaultPreferencesEditorInput
=
{
resource
:
input
.
getResource
().
toString
()
};
return
JSON
.
stringify
(
serialized
);
}
public
deserialize
(
instantiationService
:
IInstantiationService
,
serializedEditorInput
:
string
):
EditorInput
{
return
instantiationService
.
createInstance
(
SettingsEditor2Input
);
public
deserialize
(
instantiationService
:
IInstantiationService
,
serializedEditorInput
:
string
):
SettingsEditor2Input
{
const
deserialized
:
ISerializedDefaultPreferencesEditorInput
=
JSON
.
parse
(
serializedEditorInput
);
return
instantiationService
.
createInstance
(
SettingsEditor2Input
,
URI
.
parse
(
deserialized
.
resource
));
}
}
...
...
src/vs/workbench/services/preferences/browser/preferencesService.ts
浏览文件 @
cb5558b9
...
...
@@ -45,6 +45,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
_serviceBrand
:
any
;
private
lastOpenedSettingsInput
:
PreferencesEditorInput
=
null
;
private
lastOpenedSettings2Input
:
SettingsEditor2Input
=
null
;
private
readonly
_onDispose
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
...
...
@@ -176,34 +177,52 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return
this
.
editorService
.
openEditor
({
resource
:
this
.
userSettingsResource
});
}
openSettings
():
TPromise
<
IEditor
>
{
openSettings
(
jsonEditor
?:
boolean
):
TPromise
<
IEditor
>
{
if
(
!
jsonEditor
)
{
return
this
.
openSettings2
();
}
const
editorInput
=
this
.
getActiveSettingsEditorInput
()
||
this
.
lastOpenedSettingsInput
;
const
resource
=
editorInput
?
editorInput
.
master
.
getResource
()
:
this
.
userSettingsResource
;
const
target
=
this
.
getConfigurationTargetFromSettingsResource
(
resource
);
return
this
.
openOrSwitchSettings
(
target
,
resource
);
}
openGlobalSettings
(
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
return
this
.
openOrSwitchSettings
(
ConfigurationTarget
.
USER
,
this
.
userSettingsResource
,
options
,
group
);
private
openSettings2
():
TPromise
<
IEditor
>
{
const
editorInput
=
this
.
getActiveSettingsEditor2Input
()
||
this
.
lastOpenedSettings2Input
;
const
resource
=
editorInput
?
editorInput
.
getResource
()
:
this
.
userSettingsResource
;
const
target
=
this
.
getConfigurationTargetFromSettingsResource
(
resource
);
return
this
.
openOrSwitchSettings2
(
target
);
}
openSettings2
():
TPromise
<
IEditor
>
{
return
this
.
editorService
.
openEditor
(
this
.
instantiationService
.
createInstance
(
SettingsEditor2Input
),
{
pinned
:
true
}).
then
(()
=>
null
);
openGlobalSettings
(
jsonEditor
?:
boolean
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
return
jsonEditor
?
this
.
openOrSwitchSettings
(
ConfigurationTarget
.
USER
,
this
.
userSettingsResource
,
options
,
group
)
:
this
.
openOrSwitchSettings2
(
ConfigurationTarget
.
USER
,
options
,
group
);
}
openWorkspaceSettings
(
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
openWorkspaceSettings
(
jsonEditor
?:
boolean
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
if
(
this
.
contextService
.
getWorkbenchState
()
===
WorkbenchState
.
EMPTY
)
{
this
.
notificationService
.
info
(
nls
.
localize
(
'
openFolderFirst
'
,
"
Open a folder first to create workspace settings
"
));
return
TPromise
.
as
(
null
);
}
return
this
.
openOrSwitchSettings
(
ConfigurationTarget
.
WORKSPACE
,
this
.
workspaceSettingsResource
,
options
,
group
);
return
jsonEditor
?
this
.
openOrSwitchSettings
(
ConfigurationTarget
.
WORKSPACE
,
this
.
workspaceSettingsResource
,
options
,
group
)
:
this
.
openOrSwitchSettings2
(
ConfigurationTarget
.
WORKSPACE
,
options
,
group
);
}
openFolderSettings
(
folder
:
URI
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
return
this
.
openOrSwitchSettings
(
ConfigurationTarget
.
WORKSPACE_FOLDER
,
this
.
getEditableSettingsURI
(
ConfigurationTarget
.
WORKSPACE_FOLDER
,
folder
),
options
,
group
);
openFolderSettings
(
folder
:
URI
,
jsonEditor
?:
boolean
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
return
jsonEditor
?
this
.
openOrSwitchSettings
(
ConfigurationTarget
.
WORKSPACE_FOLDER
,
this
.
getEditableSettingsURI
(
ConfigurationTarget
.
WORKSPACE_FOLDER
,
folder
),
options
,
group
)
:
this
.
openOrSwitchSettings2
(
ConfigurationTarget
.
WORKSPACE_FOLDER
,
options
,
group
);
}
switchSettings
(
target
:
ConfigurationTarget
,
resource
:
URI
):
TPromise
<
void
>
{
switchSettings
(
target
:
ConfigurationTarget
,
resource
:
URI
,
jsonEditor
?:
boolean
):
TPromise
<
void
>
{
if
(
!
jsonEditor
)
{
return
this
.
switchSettings2
(
target
);
}
const
activeControl
=
this
.
editorService
.
activeControl
;
if
(
activeControl
&&
activeControl
.
input
instanceof
PreferencesEditorInput
)
{
return
this
.
doSwitchSettings
(
target
,
resource
,
activeControl
.
input
,
activeControl
.
group
).
then
(()
=>
null
);
...
...
@@ -212,6 +231,16 @@ export class PreferencesService extends Disposable implements IPreferencesServic
}
}
switchSettings2
(
target
:
ConfigurationTarget
):
TPromise
<
void
>
{
const
activeControl
=
this
.
editorService
.
activeControl
;
const
resource
=
this
.
getDefaultSettingsResource
(
target
);
if
(
activeControl
&&
activeControl
.
input
instanceof
SettingsEditor2Input
)
{
return
this
.
doSwitchSettings2
(
resource
,
activeControl
.
input
,
activeControl
.
group
).
then
(()
=>
null
);
}
else
{
return
this
.
doOpenSettings2
(
resource
).
then
(()
=>
null
);
}
}
openGlobalKeybindingSettings
(
textual
:
boolean
):
TPromise
<
void
>
{
/* __GDPR__
"openKeybindings" : {
...
...
@@ -271,6 +300,16 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return
this
.
doOpenSettings
(
configurationTarget
,
resource
,
options
,
group
);
}
private
openOrSwitchSettings2
(
configurationTarget
:
ConfigurationTarget
,
options
?:
IEditorOptions
,
group
:
IEditorGroup
=
this
.
editorGroupService
.
activeGroup
):
TPromise
<
IEditor
>
{
const
editorInput
=
this
.
getActiveSettingsEditor2Input
(
group
);
const
resource
=
this
.
getDefaultSettingsResource
(
configurationTarget
);
if
(
editorInput
&&
editorInput
.
getResource
().
fsPath
!==
resource
.
fsPath
)
{
return
this
.
doSwitchSettings2
(
resource
,
editorInput
,
group
);
}
return
this
.
doOpenSettings2
(
resource
,
options
,
group
);
}
private
doOpenSettings
(
configurationTarget
:
ConfigurationTarget
,
resource
:
URI
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
const
openDefaultSettings
=
!!
this
.
configurationService
.
getValue
(
DEFAULT_SETTINGS_EDITOR_SETTING
);
return
this
.
getOrCreateEditableSettingsEditorInput
(
configurationTarget
,
resource
)
...
...
@@ -291,6 +330,12 @@ export class PreferencesService extends Disposable implements IPreferencesServic
});
}
private
doOpenSettings2
(
resource
:
URI
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
const
settingsEditorInput
=
this
.
instantiationService
.
createInstance
(
SettingsEditor2Input
,
resource
);
this
.
lastOpenedSettings2Input
=
settingsEditorInput
;
return
this
.
editorService
.
openEditor
(
settingsEditorInput
,
options
,
group
);
}
private
doSwitchSettings
(
target
:
ConfigurationTarget
,
resource
:
URI
,
input
:
PreferencesEditorInput
,
group
:
IEditorGroup
):
TPromise
<
IEditor
>
{
return
this
.
getOrCreateEditableSettingsEditorInput
(
target
,
this
.
getEditableSettingsURI
(
target
,
resource
))
.
then
(
toInput
=>
{
...
...
@@ -308,10 +353,28 @@ export class PreferencesService extends Disposable implements IPreferencesServic
});
}
private
doSwitchSettings2
(
resource
:
URI
,
input
:
SettingsEditor2Input
,
group
:
IEditorGroup
):
TPromise
<
IEditor
>
{
return
group
.
openEditor
(
input
).
then
(()
=>
{
const
replaceWith
=
this
.
instantiationService
.
createInstance
(
SettingsEditor2Input
,
resource
);
return
group
.
replaceEditors
([{
editor
:
input
,
replacement
:
replaceWith
}]).
then
(()
=>
{
this
.
lastOpenedSettings2Input
=
replaceWith
;
return
group
.
activeControl
;
});
});
}
private
getActiveSettingsEditorInput
(
group
:
IEditorGroup
=
this
.
editorGroupService
.
activeGroup
):
PreferencesEditorInput
{
return
<
PreferencesEditorInput
>
group
.
editors
.
filter
(
e
=>
e
instanceof
PreferencesEditorInput
)[
0
];
}
private
getActiveSettingsEditor2Input
(
group
:
IEditorGroup
=
this
.
editorGroupService
.
activeGroup
):
SettingsEditor2Input
{
return
<
SettingsEditor2Input
>
group
.
editors
.
filter
(
e
=>
e
instanceof
SettingsEditor2Input
)[
0
];
}
private
getConfigurationTargetFromSettingsResource
(
resource
:
URI
):
ConfigurationTarget
{
if
(
this
.
userSettingsResource
.
toString
()
===
resource
.
toString
())
{
return
ConfigurationTarget
.
USER
;
...
...
src/vs/workbench/services/preferences/common/preferences.ts
浏览文件 @
cb5558b9
...
...
@@ -152,12 +152,11 @@ export interface IPreferencesService {
createPreferencesEditorModel
<
T
>
(
uri
:
URI
):
TPromise
<
IPreferencesEditorModel
<
T
>>
;
openRawDefaultSettings
():
TPromise
<
IEditor
>
;
openSettings
():
TPromise
<
IEditor
>
;
openSettings2
():
TPromise
<
IEditor
>
;
openGlobalSettings
(
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
;
openWorkspaceSettings
(
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
;
openFolderSettings
(
folder
:
URI
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
;
switchSettings
(
target
:
ConfigurationTarget
,
resource
:
URI
):
TPromise
<
void
>
;
openSettings
(
jsonEditor
?:
boolean
):
TPromise
<
IEditor
>
;
openGlobalSettings
(
jsonEditor
?:
boolean
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
;
openWorkspaceSettings
(
jsonEditor
?:
boolean
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
;
openFolderSettings
(
folder
:
URI
,
jsonEditor
?:
boolean
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
;
switchSettings
(
target
:
ConfigurationTarget
,
resource
:
URI
,
jsonEditor
?:
boolean
):
TPromise
<
void
>
;
openGlobalKeybindingSettings
(
textual
:
boolean
):
TPromise
<
void
>
;
openDefaultKeybindingsFile
():
TPromise
<
IEditor
>
;
...
...
src/vs/workbench/services/preferences/common/preferencesEditorInput.ts
浏览文件 @
cb5558b9
...
...
@@ -13,8 +13,6 @@ import { EditorInput, SideBySideEditorInput, Verbosity } from 'vs/workbench/comm
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
import
{
KeybindingsEditorModel
}
from
'
vs/workbench/services/preferences/common/keybindingsEditorModel
'
;
import
{
IPreferencesService
}
from
'
./preferences
'
;
import
{
DefaultSettingsEditorModel
}
from
'
./preferencesModels
'
;
export
class
PreferencesEditorInput
extends
SideBySideEditorInput
{
public
static
readonly
ID
:
string
=
'
workbench.editorinputs.preferencesEditorInput
'
;
...
...
@@ -79,29 +77,18 @@ export class KeybindingsEditorInput extends EditorInput {
}
}
export
class
SettingsEditor2Input
extends
EditorInput
{
export
class
SettingsEditor2Input
extends
Resource
EditorInput
{
public
static
readonly
ID
:
string
=
'
workbench.input.settings2
'
;
constructor
(
@
IPreferencesService
private
preferencesService
:
IPreferencesService
constructor
(
defaultSettingsResource
:
URI
,
@
ITextModelService
textModelResolverService
:
ITextModelService
,
@
IHashService
hashService
:
IHashService
)
{
super
();
super
(
nls
.
localize
(
'
settingsEditor2InputName
'
,
"
Settings (Preview)
"
),
''
,
defaultSettingsResource
,
textModelResolverService
,
hashService
);
}
getTypeId
():
string
{
return
SettingsEditor2Input
.
ID
;
}
getName
():
string
{
return
nls
.
localize
(
'
settingsEditor2InputName
'
,
"
Settings (Preview)
"
);
}
resolve
():
TPromise
<
DefaultSettingsEditorModel
>
{
return
<
TPromise
<
DefaultSettingsEditorModel
>>
this
.
preferencesService
.
createPreferencesEditorModel
(
URI
.
parse
(
'
vscode://defaultsettings/0/settings.json
'
));
}
matches
(
otherInput
:
any
):
boolean
{
return
otherInput
instanceof
SettingsEditor2Input
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录