Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8e373c4c
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,发现更多精彩内容 >>
提交
8e373c4c
编写于
8月 29, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #57470 - persist configurationTarget properly
上级
84e62f10
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
21 deletion
+59
-21
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
...vs/workbench/parts/preferences/browser/settingsEditor2.ts
+14
-0
src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts
.../preferences/electron-browser/preferences.contribution.ts
+19
-7
src/vs/workbench/services/preferences/browser/preferencesService.ts
...kbench/services/preferences/browser/preferencesService.ts
+15
-14
src/vs/workbench/services/preferences/common/preferencesEditorInput.ts
...nch/services/preferences/common/preferencesEditorInput.ts
+11
-0
未找到文件。
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
浏览文件 @
8e373c4c
...
...
@@ -160,10 +160,24 @@ export class SettingsEditor2 extends BaseEditor {
// Init TOC selection
this
.
updateTreeScrollSync
();
this
.
settingsTargetsWidget
.
settingsTarget
=
this
.
getSettingsTarget
(
input
);
this
.
onSearchInputChanged
();
});
}
private
getSettingsTarget
(
input
:
SettingsEditor2Input
):
SettingsTarget
{
if
(
input
.
folderUri
)
{
return
input
.
folderUri
;
}
if
(
input
.
configurationTarget
===
ConfigurationTarget
.
USER
||
input
.
configurationTarget
===
ConfigurationTarget
.
WORKSPACE
)
{
return
input
.
configurationTarget
;
}
return
ConfigurationTarget
.
USER
;
}
clearInput
():
void
{
this
.
inSettingsEditorContextKey
.
set
(
false
);
super
.
clearInput
();
...
...
src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts
浏览文件 @
8e373c4c
...
...
@@ -36,6 +36,7 @@ import { PreferencesSearchService } from 'vs/workbench/parts/preferences/electro
import
{
IPreferencesService
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
Command
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
Context
as
SuggestContext
}
from
'
vs/editor/contrib/suggest/suggest
'
;
import
{
ConfigurationTarget
}
from
'
vs/platform/configuration/common/configuration
'
;
registerSingleton
(
IPreferencesSearchService
,
PreferencesSearchService
);
...
...
@@ -149,24 +150,35 @@ class KeybindingsEditorInputFactory implements IEditorInputFactory {
}
}
class
SettingsEditor2InputFactory
implements
IEditorInputFactory
{
interface
ISerializedSettingsEditor2EditorInput
{
resource
:
string
;
configurationTarget
:
ConfigurationTarget
;
folderResource
?:
string
;
}
public
serialize
(
editorInput
:
SettingsEditor2Input
):
string
{
const
input
=
<
DefaultPreferencesEditorInput
>
editorInput
;
class
SettingsEditor2InputFactory
implements
IEditorInputFactory
{
const
serialized
:
ISerializedDefaultPreferencesEditorInput
=
{
resource
:
input
.
getResource
().
toString
()
};
public
serialize
(
input
:
SettingsEditor2Input
):
string
{
const
serialized
:
ISerializedSettingsEditor2EditorInput
=
{
resource
:
input
.
getResource
().
toString
(),
configurationTarget
:
input
.
configurationTarget
,
folderResource
:
input
.
folderUri
&&
input
.
folderUri
.
toString
()
};
return
JSON
.
stringify
(
serialized
);
}
public
deserialize
(
instantiationService
:
IInstantiationService
,
serializedEditorInput
:
string
):
SettingsEditor2Input
{
const
deserialized
:
ISerialized
DefaultPreferences
EditorInput
=
JSON
.
parse
(
serializedEditorInput
);
const
deserialized
:
ISerialized
SettingsEditor2
EditorInput
=
JSON
.
parse
(
serializedEditorInput
);
return
instantiationService
.
createInstance
(
SettingsEditor2Input
,
URI
.
parse
(
deserialized
.
resource
));
return
instantiationService
.
createInstance
(
SettingsEditor2Input
,
URI
.
parse
(
deserialized
.
resource
),
deserialized
.
configurationTarget
,
deserialized
.
folderResource
&&
URI
.
parse
(
deserialized
.
folderResource
));
}
}
interface
ISerializedDefaultPreferencesEditorInput
{
resource
:
string
;
}
...
...
src/vs/workbench/services/preferences/browser/preferencesService.ts
浏览文件 @
8e373c4c
...
...
@@ -198,7 +198,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
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
);
this
.
openOrSwitchSettings2
(
ConfigurationTarget
.
USER
,
undefined
,
options
,
group
);
}
openWorkspaceSettings
(
jsonEditor
?:
boolean
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
...
...
@@ -209,18 +209,19 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return
jsonEditor
?
this
.
openOrSwitchSettings
(
ConfigurationTarget
.
WORKSPACE
,
this
.
workspaceSettingsResource
,
options
,
group
)
:
this
.
openOrSwitchSettings2
(
ConfigurationTarget
.
WORKSPACE
,
options
,
group
);
this
.
openOrSwitchSettings2
(
ConfigurationTarget
.
WORKSPACE
,
undefined
,
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
);
this
.
openOrSwitchSettings2
(
ConfigurationTarget
.
WORKSPACE_FOLDER
,
folder
,
options
,
group
);
}
switchSettings
(
target
:
ConfigurationTarget
,
resource
:
URI
,
jsonEditor
?:
boolean
):
TPromise
<
void
>
{
if
(
!
jsonEditor
)
{
return
this
.
switchSettings2
(
target
);
const
folderUri
=
target
===
ConfigurationTarget
.
WORKSPACE_FOLDER
&&
resource
;
return
this
.
switchSettings2
(
target
,
folderUri
);
}
const
activeControl
=
this
.
editorService
.
activeControl
;
...
...
@@ -231,13 +232,13 @@ export class PreferencesService extends Disposable implements IPreferencesServic
}
}
switchSettings2
(
target
:
ConfigurationTarget
):
TPromise
<
void
>
{
switchSettings2
(
target
:
ConfigurationTarget
,
folderUri
?:
URI
):
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
);
return
this
.
doSwitchSettings2
(
resource
,
target
,
folderUri
,
activeControl
.
input
,
activeControl
.
group
).
then
(()
=>
null
);
}
else
{
return
this
.
doOpenSettings2
(
resource
).
then
(()
=>
null
);
return
this
.
doOpenSettings2
(
resource
,
target
,
folderUri
).
then
(()
=>
null
);
}
}
...
...
@@ -300,14 +301,14 @@ 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
>
{
private
openOrSwitchSettings2
(
configurationTarget
:
ConfigurationTarget
,
folderUri
?:
URI
,
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
.
doSwitchSettings2
(
resource
,
configurationTarget
,
folderUri
,
editorInput
,
group
);
}
return
this
.
doOpenSettings2
(
resource
,
options
,
group
);
return
this
.
doOpenSettings2
(
resource
,
configurationTarget
,
folderUri
,
options
,
group
);
}
private
doOpenSettings
(
configurationTarget
:
ConfigurationTarget
,
resource
:
URI
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
...
...
@@ -330,8 +331,8 @@ export class PreferencesService extends Disposable implements IPreferencesServic
});
}
private
doOpenSettings2
(
resource
:
URI
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
const
settingsEditorInput
=
this
.
instantiationService
.
createInstance
(
SettingsEditor2Input
,
resource
);
private
doOpenSettings2
(
resource
:
URI
,
target
:
ConfigurationTarget
,
folderUri
:
URI
|
undefined
,
options
?:
IEditorOptions
,
group
?:
IEditorGroup
):
TPromise
<
IEditor
>
{
const
settingsEditorInput
=
this
.
instantiationService
.
createInstance
(
SettingsEditor2Input
,
resource
,
target
,
folderUri
);
this
.
lastOpenedSettings2Input
=
settingsEditorInput
;
return
this
.
editorService
.
openEditor
(
settingsEditorInput
,
options
,
group
);
}
...
...
@@ -353,9 +354,9 @@ export class PreferencesService extends Disposable implements IPreferencesServic
});
}
private
doSwitchSettings2
(
resource
:
URI
,
input
:
SettingsEditor2Input
,
group
:
IEditorGroup
):
TPromise
<
IEditor
>
{
private
doSwitchSettings2
(
resource
:
URI
,
configurationTarget
:
ConfigurationTarget
,
folderUri
:
URI
|
undefined
,
input
:
SettingsEditor2Input
,
group
:
IEditorGroup
):
TPromise
<
IEditor
>
{
return
group
.
openEditor
(
input
).
then
(()
=>
{
const
replaceWith
=
this
.
instantiationService
.
createInstance
(
SettingsEditor2Input
,
resource
);
const
replaceWith
=
this
.
instantiationService
.
createInstance
(
SettingsEditor2Input
,
resource
,
configurationTarget
,
folderUri
);
return
group
.
replaceEditors
([{
editor
:
input
,
...
...
src/vs/workbench/services/preferences/common/preferencesEditorInput.ts
浏览文件 @
8e373c4c
...
...
@@ -8,6 +8,7 @@ import URI from 'vs/base/common/uri';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
ConfigurationTarget
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
EditorInput
,
SideBySideEditorInput
,
Verbosity
}
from
'
vs/workbench/common/editor
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
...
...
@@ -82,12 +83,22 @@ export class SettingsEditor2Input extends ResourceEditorInput {
public
static
readonly
ID
:
string
=
'
workbench.input.settings2
'
;
constructor
(
defaultSettingsResource
:
URI
,
private
_configurationTarget
:
ConfigurationTarget
,
private
_folderUri
:
URI
|
undefined
,
@
ITextModelService
textModelResolverService
:
ITextModelService
,
@
IHashService
hashService
:
IHashService
)
{
super
(
nls
.
localize
(
'
settingsEditor2InputName
'
,
"
Settings
"
),
''
,
defaultSettingsResource
,
textModelResolverService
,
hashService
);
}
get
configurationTarget
():
ConfigurationTarget
{
return
this
.
_configurationTarget
;
}
get
folderUri
():
URI
|
undefined
{
return
this
.
_folderUri
;
}
getTypeId
():
string
{
return
SettingsEditor2Input
.
ID
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录