Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5bca1756
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,发现更多精彩内容 >>
提交
5bca1756
编写于
9月 16, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JSONEditingService: update multiple value
上级
8fbdeb72
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
35 addition
and
31 deletion
+35
-31
src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
...workbench/contrib/extensions/browser/extensionsActions.ts
+7
-7
src/vs/workbench/contrib/localizations/browser/localizations.contribution.ts
...ntrib/localizations/browser/localizations.contribution.ts
+1
-1
src/vs/workbench/contrib/localizations/browser/localizationsActions.ts
...nch/contrib/localizations/browser/localizationsActions.ts
+1
-1
src/vs/workbench/services/configuration/browser/configuration.ts
...workbench/services/configuration/browser/configuration.ts
+1
-1
src/vs/workbench/services/configuration/common/jsonEditing.ts
...vs/workbench/services/configuration/common/jsonEditing.ts
+1
-1
src/vs/workbench/services/configuration/common/jsonEditingService.ts
...bench/services/configuration/common/jsonEditingService.ts
+12
-8
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
...ration/test/electron-browser/configurationService.test.ts
+10
-10
src/vs/workbench/services/preferences/browser/preferencesService.ts
...kbench/services/preferences/browser/preferencesService.ts
+1
-1
src/vs/workbench/services/workspace/browser/workspaceEditingService.ts
...nch/services/workspace/browser/workspaceEditingService.ts
+1
-1
未找到文件。
src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
浏览文件 @
5bca1756
...
...
@@ -2049,13 +2049,13 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
removeFrom
=
removeFrom
.
filter
(
x
=>
x
.
toLowerCase
()
!==
extensionIdLowerCase
);
return
this
.
jsonEditingService
.
write
(
workspaceConfigurationFile
,
{
[
{
key
:
'
extensions
'
,
value
:
{
recommendations
:
shouldRecommend
?
insertInto
:
removeFrom
,
unwantedRecommendations
:
shouldRecommend
?
removeFrom
:
insertInto
}
},
}
]
,
true
);
});
}
...
...
@@ -2078,19 +2078,19 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
if
(
removeFrom
.
some
(
e
=>
e
.
toLowerCase
()
===
extensionIdLowerCase
))
{
removeFrom
=
removeFrom
.
filter
(
x
=>
x
.
toLowerCase
()
!==
extensionIdLowerCase
);
removeFromPromise
=
this
.
jsonEditingService
.
write
(
extensionsFileResource
,
{
[
{
key
:
shouldRecommend
?
'
unwantedRecommendations
'
:
'
recommendations
'
,
value
:
removeFrom
},
}
]
,
true
);
}
return
removeFromPromise
.
then
(()
=>
this
.
jsonEditingService
.
write
(
extensionsFileResource
,
{
[
{
key
:
shouldRecommend
?
'
recommendations
'
:
'
unwantedRecommendations
'
,
value
:
insertInto
},
}
]
,
true
)
);
});
...
...
@@ -2115,7 +2115,7 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
.
then
(
content
=>
{
const
workspaceRecommendations
=
<
IExtensionsConfigContent
>
json
.
parse
(
content
.
value
.
toString
())[
'
extensions
'
];
if
(
!
workspaceRecommendations
||
!
workspaceRecommendations
.
recommendations
)
{
return
this
.
jsonEditingService
.
write
(
workspaceConfigurationFile
,
{
key
:
'
extensions
'
,
value
:
{
recommendations
:
[]
}
}
,
true
)
return
this
.
jsonEditingService
.
write
(
workspaceConfigurationFile
,
[{
key
:
'
extensions
'
,
value
:
{
recommendations
:
[]
}
}]
,
true
)
.
then
(()
=>
this
.
fileService
.
readFile
(
workspaceConfigurationFile
));
}
return
content
;
...
...
src/vs/workbench/contrib/localizations/browser/localizations.contribution.ts
浏览文件 @
5bca1756
...
...
@@ -79,7 +79,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
[{
label
:
updateAndRestart
?
localize
(
'
yes
'
,
"
Yes
"
)
:
localize
(
'
restart now
'
,
"
Restart Now
"
),
run
:
()
=>
{
const
updatePromise
=
updateAndRestart
?
this
.
jsonEditingService
.
write
(
this
.
environmentService
.
localeResource
,
{
key
:
'
locale
'
,
value
:
locale
}
,
true
)
:
Promise
.
resolve
(
undefined
);
const
updatePromise
=
updateAndRestart
?
this
.
jsonEditingService
.
write
(
this
.
environmentService
.
localeResource
,
[{
key
:
'
locale
'
,
value
:
locale
}]
,
true
)
:
Promise
.
resolve
(
undefined
);
updatePromise
.
then
(()
=>
this
.
windowsService
.
relaunch
({}),
e
=>
this
.
notificationService
.
error
(
e
));
}
}],
...
...
src/vs/workbench/contrib/localizations/browser/localizationsActions.ts
浏览文件 @
5bca1756
...
...
@@ -65,7 +65,7 @@ export class ConfigureLocaleAction extends Action {
}
if
(
selectedLanguage
)
{
await
this
.
jsonEditingService
.
write
(
this
.
environmentService
.
localeResource
,
{
key
:
'
locale
'
,
value
:
selectedLanguage
.
label
}
,
true
);
await
this
.
jsonEditingService
.
write
(
this
.
environmentService
.
localeResource
,
[{
key
:
'
locale
'
,
value
:
selectedLanguage
.
label
}]
,
true
);
const
restart
=
await
this
.
dialogService
.
confirm
({
type
:
'
info
'
,
message
:
localize
(
'
relaunchDisplayLanguageMessage
'
,
"
A restart is required for the change in display language to take effect.
"
),
...
...
src/vs/workbench/services/configuration/browser/configuration.ts
浏览文件 @
5bca1756
...
...
@@ -337,7 +337,7 @@ export class WorkspaceConfiguration extends Disposable {
setFolders
(
folders
:
IStoredWorkspaceFolder
[],
jsonEditingService
:
JSONEditingService
):
Promise
<
void
>
{
if
(
this
.
_workspaceIdentifier
)
{
return
jsonEditingService
.
write
(
this
.
_workspaceIdentifier
.
configPath
,
{
key
:
'
folders
'
,
value
:
folders
}
,
true
)
return
jsonEditingService
.
write
(
this
.
_workspaceIdentifier
.
configPath
,
[{
key
:
'
folders
'
,
value
:
folders
}]
,
true
)
.
then
(()
=>
this
.
reload
());
}
return
Promise
.
resolve
();
...
...
src/vs/workbench/services/configuration/common/jsonEditing.ts
浏览文件 @
5bca1756
...
...
@@ -36,5 +36,5 @@ export interface IJSONEditingService {
_serviceBrand
:
undefined
;
write
(
resource
:
URI
,
value
:
IJSONValue
,
save
:
boolean
):
Promise
<
void
>
;
write
(
resource
:
URI
,
value
s
:
IJSONValue
[]
,
save
:
boolean
):
Promise
<
void
>
;
}
src/vs/workbench/services/configuration/common/jsonEditingService.ts
浏览文件 @
5bca1756
...
...
@@ -35,20 +35,24 @@ export class JSONEditingService implements IJSONEditingService {
this
.
queue
=
new
Queue
<
void
>
();
}
write
(
resource
:
URI
,
value
:
IJSONValue
,
save
:
boolean
):
Promise
<
void
>
{
return
Promise
.
resolve
(
this
.
queue
.
queue
(()
=>
this
.
doWriteConfiguration
(
resource
,
value
,
save
)));
// queue up writes to prevent race conditions
write
(
resource
:
URI
,
value
s
:
IJSONValue
[]
,
save
:
boolean
):
Promise
<
void
>
{
return
Promise
.
resolve
(
this
.
queue
.
queue
(()
=>
this
.
doWriteConfiguration
(
resource
,
value
s
,
save
)));
// queue up writes to prevent race conditions
}
private
async
doWriteConfiguration
(
resource
:
URI
,
value
:
IJSONValue
,
save
:
boolean
):
Promise
<
void
>
{
private
async
doWriteConfiguration
(
resource
:
URI
,
value
s
:
IJSONValue
[]
,
save
:
boolean
):
Promise
<
void
>
{
const
reference
=
await
this
.
resolveAndValidate
(
resource
,
save
);
await
this
.
writeToBuffer
(
reference
.
object
.
textEditorModel
,
value
);
await
this
.
writeToBuffer
(
reference
.
object
.
textEditorModel
,
value
s
);
reference
.
dispose
();
}
private
async
writeToBuffer
(
model
:
ITextModel
,
value
:
IJSONValue
):
Promise
<
any
>
{
const
edit
=
this
.
getEdits
(
model
,
value
)[
0
];
if
(
this
.
applyEditsToBuffer
(
edit
,
model
))
{
private
async
writeToBuffer
(
model
:
ITextModel
,
values
:
IJSONValue
[]):
Promise
<
any
>
{
let
hasEdits
:
boolean
=
false
;
for
(
const
value
of
values
)
{
const
edit
=
this
.
getEdits
(
model
,
value
)[
0
];
hasEdits
=
this
.
applyEditsToBuffer
(
edit
,
model
);
}
if
(
hasEdits
)
{
return
this
.
textFileService
.
save
(
model
.
uri
);
}
}
...
...
@@ -133,4 +137,4 @@ export class JSONEditingService implements IJSONEditingService {
}
}
registerSingleton
(
IJSONEditingService
,
JSONEditingService
,
true
);
\ No newline at end of file
registerSingleton
(
IJSONEditingService
,
JSONEditingService
,
true
);
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
浏览文件 @
5bca1756
...
...
@@ -1161,21 +1161,21 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
test
(
'
application settings are not read from workspace
'
,
()
=>
{
fs
.
writeFileSync
(
globalSettingsFile
,
'
{ "configurationService.workspace.applicationSetting": "userValue" }
'
);
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.applicationSetting
'
:
'
workspaceValue
'
}
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.applicationSetting
'
:
'
workspaceValue
'
}
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
assert
.
equal
(
testObject
.
getValue
(
'
configurationService.workspace.applicationSetting
'
),
'
userValue
'
));
});
test
(
'
machine settings are not read from workspace
'
,
()
=>
{
fs
.
writeFileSync
(
globalSettingsFile
,
'
{ "configurationService.workspace.machineSetting": "userValue" }
'
);
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.machineSetting
'
:
'
workspaceValue
'
}
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.machineSetting
'
:
'
workspaceValue
'
}
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
assert
.
equal
(
testObject
.
getValue
(
'
configurationService.workspace.machineSetting
'
),
'
userValue
'
));
});
test
(
'
workspace settings override user settings after defaults are registered
'
,
()
=>
{
fs
.
writeFileSync
(
globalSettingsFile
,
'
{ "configurationService.workspace.newSetting": "userValue" }
'
);
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.newSetting
'
:
'
workspaceValue
'
}
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.newSetting
'
:
'
workspaceValue
'
}
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
configurationRegistry
.
registerConfiguration
({
...
...
@@ -1194,7 +1194,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
test
(
'
workspace settings override user settings after defaults are registered for machine overridable settings
'
,
()
=>
{
fs
.
writeFileSync
(
globalSettingsFile
,
'
{ "configurationService.workspace.newMachineOverridableSetting": "userValue" }
'
);
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.newMachineOverridableSetting
'
:
'
workspaceValue
'
}
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.newMachineOverridableSetting
'
:
'
workspaceValue
'
}
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
configurationRegistry
.
registerConfiguration
({
...
...
@@ -1268,7 +1268,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
test
(
'
resource setting in folder is read after it is registered later
'
,
()
=>
{
fs
.
writeFileSync
(
workspaceContextService
.
getWorkspace
().
folders
[
0
].
toResource
(
'
.vscode/settings.json
'
).
fsPath
,
'
{ "configurationService.workspace.testNewResourceSetting2": "workspaceFolderValue" }
'
);
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.testNewResourceSetting2
'
:
'
workspaceValue
'
}
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.testNewResourceSetting2
'
:
'
workspaceValue
'
}
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
configurationRegistry
.
registerConfiguration
({
...
...
@@ -1288,7 +1288,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
test
(
'
machine overridable setting in folder is read after it is registered later
'
,
()
=>
{
fs
.
writeFileSync
(
workspaceContextService
.
getWorkspace
().
folders
[
0
].
toResource
(
'
.vscode/settings.json
'
).
fsPath
,
'
{ "configurationService.workspace.testNewMachineOverridableSetting2": "workspaceFolderValue" }
'
);
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.testNewMachineOverridableSetting2
'
:
'
workspaceValue
'
}
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.testNewMachineOverridableSetting2
'
:
'
workspaceValue
'
}
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
configurationRegistry
.
registerConfiguration
({
...
...
@@ -1331,7 +1331,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
assert
.
equal
(
actual
.
workspaceFolder
,
undefined
);
assert
.
equal
(
actual
.
value
,
'
userValue
'
);
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.testResourceSetting
'
:
'
workspaceValue
'
}
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
settings
'
,
value
:
{
'
configurationService.workspace.testResourceSetting
'
:
'
workspaceValue
'
}
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
actual
=
testObject
.
inspect
(
'
configurationService.workspace.testResourceSetting
'
);
...
...
@@ -1373,7 +1373,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
}
]
};
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
launch
'
,
value
:
expectedLaunchConfiguration
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
launch
'
,
value
:
expectedLaunchConfiguration
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
const
actual
=
testObject
.
getValue
(
'
launch
'
);
...
...
@@ -1398,7 +1398,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
}
]
};
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
launch
'
,
value
:
expectedLaunchConfiguration
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
launch
'
,
value
:
expectedLaunchConfiguration
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
const
actual
=
testObject
.
inspect
(
'
launch
'
).
workspace
;
...
...
@@ -1496,7 +1496,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
});
test
(
'
task configurations are not read from workspace
'
,
()
=>
{
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
{
key
:
'
tasks
'
,
value
:
{
'
version
'
:
'
1.0
'
}
}
,
true
)
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
!
,
[{
key
:
'
tasks
'
,
value
:
{
'
version
'
:
'
1.0
'
}
}]
,
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
const
actual
=
testObject
.
inspect
(
'
tasks.version
'
);
...
...
src/vs/workbench/services/preferences/browser/preferencesService.ts
浏览文件 @
5bca1756
...
...
@@ -557,7 +557,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return
this
.
textFileService
.
read
(
workspaceConfig
)
.
then
(
content
=>
{
if
(
Object
.
keys
(
parse
(
content
.
value
)).
indexOf
(
'
settings
'
)
===
-
1
)
{
return
this
.
jsonEditingService
.
write
(
resource
,
{
key
:
'
settings
'
,
value
:
{}
}
,
true
).
then
(
undefined
,
()
=>
{
});
return
this
.
jsonEditingService
.
write
(
resource
,
[{
key
:
'
settings
'
,
value
:
{}
}]
,
true
).
then
(
undefined
,
()
=>
{
});
}
return
undefined
;
});
...
...
src/vs/workbench/services/workspace/browser/workspaceEditingService.ts
浏览文件 @
5bca1756
...
...
@@ -448,7 +448,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
}
}
return
this
.
jsonEditingService
.
write
(
toWorkspace
.
configPath
,
{
key
:
'
settings
'
,
value
:
targetWorkspaceConfiguration
}
,
true
);
return
this
.
jsonEditingService
.
write
(
toWorkspace
.
configPath
,
[{
key
:
'
settings
'
,
value
:
targetWorkspaceConfiguration
}]
,
true
);
}
private
getCurrentWorkspaceIdentifier
():
IWorkspaceIdentifier
|
undefined
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录