Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
179adc5f
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,发现更多精彩内容 >>
提交
179adc5f
编写于
12月 15, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support removing a setting from all targets
上级
284ace0b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
19 deletion
+55
-19
src/vs/workbench/services/configuration/browser/configurationService.ts
...ch/services/configuration/browser/configurationService.ts
+25
-19
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
...ration/test/electron-browser/configurationService.test.ts
+30
-0
未找到文件。
src/vs/workbench/services/configuration/browser/configurationService.ts
浏览文件 @
179adc5f
...
@@ -293,19 +293,20 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
...
@@ -293,19 +293,20 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
async
updateValue
(
key
:
string
,
value
:
any
,
arg3
?:
any
,
arg4
?:
any
,
donotNotifyError
?:
any
):
Promise
<
void
>
{
async
updateValue
(
key
:
string
,
value
:
any
,
arg3
?:
any
,
arg4
?:
any
,
donotNotifyError
?:
any
):
Promise
<
void
>
{
await
this
.
cyclicDependency
;
await
this
.
cyclicDependency
;
const
overrides
=
isConfigurationOverrides
(
arg3
)
?
arg3
:
undefined
;
const
overrides
=
isConfigurationOverrides
(
arg3
)
?
arg3
:
undefined
;
let
target
:
ConfigurationTarget
|
undefined
=
overrides
?
arg4
:
arg3
;
const
target
:
ConfigurationTarget
|
undefined
=
overrides
?
arg4
:
arg3
;
const
targets
:
ConfigurationTarget
[]
=
target
?
[
target
]
:
[];
if
(
!
target
)
{
if
(
!
target
s
.
length
)
{
const
inspect
=
this
.
inspect
(
key
,
overrides
);
const
inspect
=
this
.
inspect
(
key
,
overrides
);
target
=
this
.
deriveConfigurationTarget
(
key
,
value
,
inspect
);
targets
.
push
(...
this
.
deriveConfigurationTargets
(
key
,
value
,
inspect
));
if
(
target
===
ConfigurationTarget
.
USER
&&
equals
(
value
,
inspect
.
defaultValue
))
{
// Remove the setting, if the value is same as default value and is updated only in user target
if
(
equals
(
value
,
inspect
.
defaultValue
)
&&
targets
.
length
===
1
&&
(
targets
[
0
]
===
ConfigurationTarget
.
USER
||
targets
[
0
]
===
ConfigurationTarget
.
USER_LOCAL
))
{
value
=
undefined
;
value
=
undefined
;
}
}
}
}
if
(
target
)
{
await
Promise
.
all
(
targets
.
map
(
target
=>
this
.
writeConfigurationValue
(
key
,
value
,
target
,
overrides
,
donotNotifyError
)));
await
this
.
writeConfigurationValue
(
key
,
value
,
target
,
overrides
,
donotNotifyError
);
}
}
}
async
reloadConfiguration
(
target
?:
ConfigurationTarget
|
IWorkspaceFolder
):
Promise
<
void
>
{
async
reloadConfiguration
(
target
?:
ConfigurationTarget
|
IWorkspaceFolder
):
Promise
<
void
>
{
...
@@ -759,26 +760,31 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
...
@@ -759,26 +760,31 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
});
});
}
}
private
deriveConfigurationTarget
(
key
:
string
,
value
:
any
,
inspect
:
IConfigurationValue
<
any
>
):
ConfigurationTarget
|
undefined
{
private
deriveConfigurationTargets
(
key
:
string
,
value
:
any
,
inspect
:
IConfigurationValue
<
any
>
):
ConfigurationTarget
[]
{
if
(
value
===
undefined
)
{
// Ignore. But expected is to remove the value from all targets
return
undefined
;
}
if
(
equals
(
value
,
inspect
.
value
))
{
if
(
equals
(
value
,
inspect
.
value
))
{
// No change. So ignore.
return
[];
return
undefined
;
}
}
const
definedTargets
:
ConfigurationTarget
[]
=
[];
if
(
inspect
.
workspaceFolderValue
!==
undefined
)
{
if
(
inspect
.
workspaceFolderValue
!==
undefined
)
{
return
ConfigurationTarget
.
WORKSPACE_FOLDER
;
definedTargets
.
push
(
ConfigurationTarget
.
WORKSPACE_FOLDER
)
;
}
}
if
(
inspect
.
workspaceValue
!==
undefined
)
{
if
(
inspect
.
workspaceValue
!==
undefined
)
{
return
ConfigurationTarget
.
WORKSPACE
;
definedTargets
.
push
(
ConfigurationTarget
.
WORKSPACE
);
}
if
(
inspect
.
userRemoteValue
!==
undefined
)
{
definedTargets
.
push
(
ConfigurationTarget
.
USER_REMOTE
);
}
if
(
inspect
.
userLocalValue
!==
undefined
)
{
definedTargets
.
push
(
ConfigurationTarget
.
USER_LOCAL
);
}
if
(
value
===
undefined
)
{
// Remove the setting in all defined targets
return
definedTargets
;
}
}
return
ConfigurationTarget
.
USER
;
return
[
definedTargets
[
0
]
||
ConfigurationTarget
.
USER
]
;
}
}
private
triggerConfigurationChange
(
change
:
IConfigurationChange
,
previous
:
{
data
:
IConfigurationData
,
workspace
?:
Workspace
}
|
undefined
,
target
:
ConfigurationTarget
):
void
{
private
triggerConfigurationChange
(
change
:
IConfigurationChange
,
previous
:
{
data
:
IConfigurationData
,
workspace
?:
Workspace
}
|
undefined
,
target
:
ConfigurationTarget
):
void
{
...
...
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
浏览文件 @
179adc5f
...
@@ -1174,6 +1174,20 @@ suite('WorkspaceConfigurationService - Folder', () => {
...
@@ -1174,6 +1174,20 @@ suite('WorkspaceConfigurationService - Folder', () => {
.
then
(()
=>
assert
.
ok
(
target
.
called
));
.
then
(()
=>
assert
.
ok
(
target
.
called
));
});
});
test
(
'
remove setting from all targets
'
,
async
()
=>
{
const
key
=
'
configurationService.folder.testSetting
'
;
await
testObject
.
updateValue
(
key
,
'
workspaceValue
'
,
ConfigurationTarget
.
WORKSPACE
);
await
testObject
.
updateValue
(
key
,
'
userValue
'
,
ConfigurationTarget
.
USER
);
await
testObject
.
updateValue
(
key
,
undefined
);
await
testObject
.
reloadConfiguration
();
const
actual
=
testObject
.
inspect
(
key
,
{
resource
:
workspaceService
.
getWorkspace
().
folders
[
0
].
uri
});
assert
.
equal
(
actual
.
userValue
,
undefined
);
assert
.
equal
(
actual
.
workspaceValue
,
undefined
);
assert
.
equal
(
actual
.
workspaceFolderValue
,
undefined
);
});
test
(
'
update user configuration to default value when target is not passed
'
,
async
()
=>
{
test
(
'
update user configuration to default value when target is not passed
'
,
async
()
=>
{
await
testObject
.
updateValue
(
'
configurationService.folder.testSetting
'
,
'
value
'
,
ConfigurationTarget
.
USER
);
await
testObject
.
updateValue
(
'
configurationService.folder.testSetting
'
,
'
value
'
,
ConfigurationTarget
.
USER
);
await
testObject
.
updateValue
(
'
configurationService.folder.testSetting
'
,
'
isSet
'
);
await
testObject
.
updateValue
(
'
configurationService.folder.testSetting
'
,
'
isSet
'
);
...
@@ -1805,6 +1819,22 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
...
@@ -1805,6 +1819,22 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
.
then
(()
=>
assert
.
ok
(
target
.
called
));
.
then
(()
=>
assert
.
ok
(
target
.
called
));
});
});
test
(
'
remove setting from all targets
'
,
async
()
=>
{
const
workspace
=
workspaceContextService
.
getWorkspace
();
const
key
=
'
configurationService.workspace.testResourceSetting
'
;
await
testObject
.
updateValue
(
key
,
'
workspaceFolderValue
'
,
{
resource
:
workspace
.
folders
[
0
].
uri
},
ConfigurationTarget
.
WORKSPACE_FOLDER
);
await
testObject
.
updateValue
(
key
,
'
workspaceValue
'
,
ConfigurationTarget
.
WORKSPACE
);
await
testObject
.
updateValue
(
key
,
'
userValue
'
,
ConfigurationTarget
.
USER
);
await
testObject
.
updateValue
(
key
,
undefined
,
{
resource
:
workspace
.
folders
[
0
].
uri
});
await
testObject
.
reloadConfiguration
();
const
actual
=
testObject
.
inspect
(
key
,
{
resource
:
workspace
.
folders
[
0
].
uri
});
assert
.
equal
(
actual
.
userValue
,
undefined
);
assert
.
equal
(
actual
.
workspaceValue
,
undefined
);
assert
.
equal
(
actual
.
workspaceFolderValue
,
undefined
);
});
test
(
'
update tasks configuration in a folder
'
,
()
=>
{
test
(
'
update tasks configuration in a folder
'
,
()
=>
{
const
workspace
=
workspaceContextService
.
getWorkspace
();
const
workspace
=
workspaceContextService
.
getWorkspace
();
return
testObject
.
updateValue
(
'
tasks
'
,
{
'
version
'
:
'
1.0.0
'
,
tasks
:
[{
'
taskName
'
:
'
myTask
'
}]
},
{
resource
:
workspace
.
folders
[
0
].
uri
},
ConfigurationTarget
.
WORKSPACE_FOLDER
)
return
testObject
.
updateValue
(
'
tasks
'
,
{
'
version
'
:
'
1.0.0
'
,
tasks
:
[{
'
taskName
'
:
'
myTask
'
}]
},
{
resource
:
workspace
.
folders
[
0
].
uri
},
ConfigurationTarget
.
WORKSPACE_FOLDER
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录