Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
854228de
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,发现更多精彩内容 >>
提交
854228de
编写于
12月 01, 2016
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tests contain output. Fixes #16315
上级
5745beb9
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
34 addition
and
18 deletion
+34
-18
src/vs/platform/configuration/common/model.ts
src/vs/platform/configuration/common/model.ts
+11
-7
src/vs/platform/configuration/node/configurationService.ts
src/vs/platform/configuration/node/configurationService.ts
+1
-1
src/vs/workbench/api/node/extHostConfiguration.ts
src/vs/workbench/api/node/extHostConfiguration.ts
+1
-1
src/vs/workbench/services/configuration/common/model.ts
src/vs/workbench/services/configuration/common/model.ts
+2
-2
src/vs/workbench/services/configuration/node/configurationService.ts
...bench/services/configuration/node/configurationService.ts
+2
-2
src/vs/workbench/test/node/api/extHostConfiguration.test.ts
src/vs/workbench/test/node/api/extHostConfiguration.test.ts
+17
-5
未找到文件。
src/vs/platform/configuration/common/model.ts
浏览文件 @
854228de
...
...
@@ -13,28 +13,29 @@ export function getDefaultValues(): any {
for
(
let
key
in
properties
)
{
let
value
=
properties
[
key
].
default
;
addToValueTree
(
valueTreeRoot
,
key
,
value
);
addToValueTree
(
valueTreeRoot
,
key
,
value
,
message
=>
console
.
error
(
`Conflict in default settings:
${
message
}
`
)
);
}
return
valueTreeRoot
;
}
export
function
toValuesTree
(
properties
:
{
[
qualifiedKey
:
string
]:
any
}):
any
{
export
function
toValuesTree
(
properties
:
{
[
qualifiedKey
:
string
]:
any
}
,
conflictReporter
:
(
message
:
string
)
=>
void
):
any
{
const
root
=
Object
.
create
(
null
);
for
(
let
key
in
properties
)
{
addToValueTree
(
root
,
key
,
properties
[
key
]);
addToValueTree
(
root
,
key
,
properties
[
key
]
,
conflictReporter
);
}
return
root
;
}
function
addToValueTree
(
settingsTreeRoot
:
any
,
key
:
string
,
value
:
any
):
void
{
function
addToValueTree
(
settingsTreeRoot
:
any
,
key
:
string
,
value
:
any
,
conflictReporter
:
(
message
:
string
)
=>
void
):
void
{
const
segments
=
key
.
split
(
'
.
'
);
const
last
=
segments
.
pop
();
let
curr
=
settingsTreeRoot
;
segments
.
forEach
(
s
=>
{
for
(
let
i
=
0
;
i
<
segments
.
length
;
i
++
)
{
let
s
=
segments
[
i
];
let
obj
=
curr
[
s
];
switch
(
typeof
obj
)
{
case
'
undefined
'
:
...
...
@@ -43,13 +44,16 @@ function addToValueTree(settingsTreeRoot: any, key: string, value: any): void {
case
'
object
'
:
break
;
default
:
console
.
error
(
`Conflicting configuration setting:
${
key
}
at
${
s
}
with
${
JSON
.
stringify
(
obj
)}
`
);
conflictReporter
(
`Ignoring
${
key
}
as
${
segments
.
slice
(
0
,
i
+
1
).
join
(
'
.
'
)}
is
${
JSON
.
stringify
(
obj
)}
`
);
return
;
}
curr
=
obj
;
}
)
;
};
if
(
typeof
curr
===
'
object
'
)
{
curr
[
last
]
=
value
;
// workaround https://github.com/Microsoft/vscode/issues/13606
}
else
{
conflictReporter
(
`Ignoring
${
key
}
as
${
segments
.
join
(
'
.
'
)}
is
${
JSON
.
stringify
(
curr
)}
`
);
}
}
...
...
src/vs/platform/configuration/node/configurationService.ts
浏览文件 @
854228de
...
...
@@ -104,7 +104,7 @@ export class ConfigurationService<T> implements IConfigurationService, IDisposab
private
consolidateConfigurations
():
ICache
<
T
>
{
const
defaults
=
getDefaultValues
();
// defaults coming from contributions to registries
const
user
=
toValuesTree
(
this
.
rawConfig
.
getConfig
());
// user configured settings
const
user
=
toValuesTree
(
this
.
rawConfig
.
getConfig
()
,
message
=>
console
.
error
(
`Conflict in user settings:
${
message
}
`
)
);
// user configured settings
const
consolidated
=
objects
.
mixin
(
objects
.
clone
(
defaults
),
// target: default values (but dont modify!)
...
...
src/vs/workbench/api/node/extHostConfiguration.ts
浏览文件 @
854228de
...
...
@@ -35,7 +35,7 @@ function createUsefulConfiguration(data: IWorkspaceConfigurationValues): { data:
valueMap
[
key
]
=
data
[
key
].
value
;
}
}
const
valueTree
=
toValuesTree
(
valueMap
);
const
valueTree
=
toValuesTree
(
valueMap
,
message
=>
console
.
error
(
`Conflict in configuration settings:
${
message
}
`
)
);
return
{
data
,
valueTree
...
...
src/vs/workbench/services/configuration/common/model.ts
浏览文件 @
854228de
...
...
@@ -16,11 +16,11 @@ export interface IConfigFile {
parseError
?:
any
;
}
export
function
newConfigFile
(
value
:
string
):
IConfigFile
{
export
function
newConfigFile
(
value
:
string
,
fileName
:
string
):
IConfigFile
{
try
{
const
contents
=
json
.
parse
(
value
)
||
{};
return
{
contents
:
toValuesTree
(
contents
),
contents
:
toValuesTree
(
contents
,
message
=>
console
.
error
(
`Conflict in settings file
${
fileName
}
:
${
message
}
`
)
),
raw
:
contents
};
}
catch
(
e
)
{
...
...
src/vs/workbench/services/configuration/node/configurationService.ts
浏览文件 @
854228de
...
...
@@ -253,7 +253,7 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
return
[];
// never fail this call
}
}).
then
((
contents
:
IContent
[])
=>
{
contents
.
forEach
(
content
=>
this
.
workspaceFilePathToConfiguration
[
this
.
contextService
.
toWorkspaceRelativePath
(
content
.
resource
)]
=
TPromise
.
as
(
newConfigFile
(
content
.
value
)));
contents
.
forEach
(
content
=>
this
.
workspaceFilePathToConfiguration
[
this
.
contextService
.
toWorkspaceRelativePath
(
content
.
resource
)]
=
TPromise
.
as
(
newConfigFile
(
content
.
value
,
content
.
resource
.
toString
()
)));
},
errors
.
onUnexpectedError
);
}
...
...
@@ -298,7 +298,7 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
break
;
case
FileChangeType
.
UPDATED
:
case
FileChangeType
.
ADDED
:
this
.
workspaceFilePathToConfiguration
[
workspacePath
]
=
resolveContent
(
resource
).
then
(
content
=>
newConfigFile
(
content
.
value
),
errors
.
onUnexpectedError
);
this
.
workspaceFilePathToConfiguration
[
workspacePath
]
=
resolveContent
(
resource
).
then
(
content
=>
newConfigFile
(
content
.
value
,
content
.
resource
.
toString
()
),
errors
.
onUnexpectedError
);
affectedByChanges
=
true
;
}
}
...
...
src/vs/workbench/test/node/api/extHostConfiguration.test.ts
浏览文件 @
854228de
...
...
@@ -156,12 +156,24 @@ suite('ExtHostConfiguration', function () {
});
test
(
'
bogous data, #15834
'
,
function
()
{
let
oldLogger
=
console
.
error
;
let
errorLogged
=
false
;
// workaround until we have a proper logging story
console
.
error
=
(
message
,
args
)
=>
{
errorLogged
=
true
;
};
let
allConfig
;
try
{
const
shape
=
new
RecordingShape
();
const
allConfig
=
createExtHostConfiguration
({
allConfig
=
createExtHostConfiguration
({
[
'
editor.formatOnSave
'
]:
createConfigurationValue
(
true
),
[
'
editor.formatOnSave.extensions
'
]:
createConfigurationValue
([
'
ts
'
])
},
shape
);
}
finally
{
console
.
error
=
oldLogger
;
}
assert
.
ok
(
errorLogged
);
assert
.
ok
(
allConfig
.
getConfiguration
(
''
).
has
(
'
editor.formatOnSave
'
));
assert
.
ok
(
!
allConfig
.
getConfiguration
(
''
).
has
(
'
editor.formatOnSave.extensions
'
));
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录