Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
0fbe44a2
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0fbe44a2
编写于
3月 27, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #92288
上级
69c72a05
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
5 deletion
+41
-5
src/vs/workbench/services/configuration/browser/configuration.ts
...workbench/services/configuration/browser/configuration.ts
+3
-3
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
...ration/test/electron-browser/configurationService.test.ts
+38
-2
未找到文件。
src/vs/workbench/services/configuration/browser/configuration.ts
浏览文件 @
0fbe44a2
...
...
@@ -59,7 +59,7 @@ export class UserConfiguration extends Disposable {
const
fileServiceBasedConfiguration
=
new
FileServiceBasedConfiguration
(
folder
.
toString
(),
[
this
.
userSettingsResource
],
standAloneConfigurationResources
,
this
.
scopes
,
this
.
fileService
);
const
configurationModel
=
await
fileServiceBasedConfiguration
.
loadConfiguration
();
this
.
userConfiguration
.
value
=
fileServiceBasedConfiguration
;
this
.
_register
(
this
.
userConfiguration
.
value
.
onDidChange
(()
=>
this
.
reloadConfigurationScheduler
.
schedule
()));
this
.
_register
(
fileServiceBasedConfiguration
.
onDidChange
(()
=>
this
.
reloadConfigurationScheduler
.
schedule
()));
return
configurationModel
;
}
...
...
@@ -108,7 +108,7 @@ class FileServiceBasedConfiguration extends Disposable {
errors
.
onUnexpectedError
(
error
);
}
}
return
undefined
;
return
'
{}
'
;
}));
};
...
...
@@ -723,6 +723,7 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
this
.
folderConfiguration
=
this
.
cachedFolderConfiguration
=
new
CachedFolderConfiguration
(
workspaceFolder
.
uri
,
configFolderRelativePath
,
configurationCache
);
if
(
workspaceFolder
.
uri
.
scheme
===
Schemas
.
file
)
{
this
.
folderConfiguration
=
this
.
createFileServiceBasedConfiguration
(
fileService
);
this
.
folderConfigurationDisposable
=
this
.
_register
(
this
.
folderConfiguration
.
onDidChange
(
e
=>
this
.
onDidFolderConfigurationChange
()));
}
else
{
whenProviderRegistered
(
workspaceFolder
.
uri
,
fileService
)
.
then
(()
=>
{
...
...
@@ -733,7 +734,6 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
this
.
onDidFolderConfigurationChange
();
});
}
this
.
folderConfigurationDisposable
=
this
.
_register
(
this
.
folderConfiguration
.
onDidChange
(
e
=>
this
.
onDidFolderConfigurationChange
()));
}
loadConfiguration
():
Promise
<
ConfigurationModel
>
{
...
...
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
浏览文件 @
0fbe44a2
...
...
@@ -30,7 +30,7 @@ import { IJSONEditingService } from 'vs/workbench/services/configuration/common/
import
{
JSONEditingService
}
from
'
vs/workbench/services/configuration/common/jsonEditingService
'
;
import
{
createHash
}
from
'
crypto
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
originalFSPath
}
from
'
vs/base/common/resources
'
;
import
{
originalFSPath
,
joinPath
}
from
'
vs/base/common/resources
'
;
import
{
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
RemoteAgentService
}
from
'
vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl
'
;
import
{
RemoteAuthorityResolverService
}
from
'
vs/platform/remote/electron-browser/remoteAuthorityResolverService
'
;
...
...
@@ -47,6 +47,7 @@ import { IKeybindingEditingService, KeybindingsEditingService } from 'vs/workben
import
{
NativeWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/electron-browser/environmentService
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
timeout
}
from
'
vs/base/common/async
'
;
import
{
VSBuffer
}
from
'
vs/base/common/buffer
'
;
class
TestEnvironmentService
extends
NativeWorkbenchEnvironmentService
{
...
...
@@ -719,6 +720,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
let
workspaceName
=
`testWorkspace
${
uuid
.
generateUuid
()}
`
,
parentResource
:
string
,
workspaceDir
:
string
,
testObject
:
IConfigurationService
,
globalSettingsFile
:
string
,
globalTasksFile
:
string
,
workspaceService
:
WorkspaceService
;
const
configurationRegistry
=
Registry
.
as
<
IConfigurationRegistry
>
(
ConfigurationExtensions
.
Configuration
);
let
fileService
:
IFileService
;
suiteSetup
(()
=>
{
configurationRegistry
.
registerConfiguration
({
...
...
@@ -767,7 +769,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
const
environmentService
=
new
TestEnvironmentService
(
URI
.
file
(
parentDir
));
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
fileService
=
new
FileService
(
new
NullLogService
());
fileService
=
new
FileService
(
new
NullLogService
());
const
diskFileSystemProvider
=
new
DiskFileSystemProvider
(
new
NullLogService
());
fileService
.
registerProvider
(
Schemas
.
file
,
diskFileSystemProvider
);
fileService
.
registerProvider
(
Schemas
.
userData
,
new
FileUserDataProvider
(
environmentService
.
appSettingsHome
,
environmentService
.
backupHome
,
diskFileSystemProvider
,
environmentService
));
...
...
@@ -776,6 +778,9 @@ suite('WorkspaceConfigurationService - Folder', () => {
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
// Watch workspace configuration directory
fileService
.
watch
(
joinPath
(
URI
.
file
(
workspaceDir
),
'
.vscode
'
));
return
workspaceService
.
initialize
(
convertToWorkspacePayload
(
URI
.
file
(
folderDir
))).
then
(()
=>
{
instantiationService
.
stub
(
IFileService
,
fileService
);
instantiationService
.
stub
(
IKeybindingEditingService
,
instantiationService
.
createInstance
(
KeybindingsEditingService
));
...
...
@@ -1101,6 +1106,37 @@ suite('WorkspaceConfigurationService - Folder', () => {
fs
.
writeFileSync
(
globalTasksFile
,
'
{ "version": "1.0.0", "tasks": [{ "taskName": "myTask" }
'
);
return
new
Promise
((
c
)
=>
testObject
.
onDidChangeConfiguration
(()
=>
c
()));
});
test
(
'
creating workspace settings
'
,
async
()
=>
{
fs
.
writeFileSync
(
globalSettingsFile
,
'
{ "configurationService.folder.testSetting": "userValue" }
'
);
await
testObject
.
reloadConfiguration
();
const
workspaceSettingsResource
=
URI
.
file
(
path
.
join
(
workspaceDir
,
'
.vscode
'
,
'
settings.json
'
));
await
new
Promise
(
async
(
c
)
=>
{
const
disposable
=
testObject
.
onDidChangeConfiguration
(
e
=>
{
assert
.
ok
(
e
.
affectsConfiguration
(
'
configurationService.folder.testSetting
'
));
assert
.
equal
(
testObject
.
getValue
(
'
configurationService.folder.testSetting
'
),
'
workspaceValue
'
);
disposable
.
dispose
();
c
();
});
await
fileService
.
writeFile
(
workspaceSettingsResource
,
VSBuffer
.
fromString
(
'
{ "configurationService.folder.testSetting": "workspaceValue" }
'
));
});
});
test
(
'
deleting workspace settings
'
,
async
()
=>
{
fs
.
writeFileSync
(
globalSettingsFile
,
'
{ "configurationService.folder.testSetting": "userValue" }
'
);
const
workspaceSettingsResource
=
URI
.
file
(
path
.
join
(
workspaceDir
,
'
.vscode
'
,
'
settings.json
'
));
await
fileService
.
writeFile
(
workspaceSettingsResource
,
VSBuffer
.
fromString
(
'
{ "configurationService.folder.testSetting": "workspaceValue" }
'
));
await
testObject
.
reloadConfiguration
();
await
new
Promise
(
async
(
c
)
=>
{
const
disposable
=
testObject
.
onDidChangeConfiguration
(
e
=>
{
assert
.
ok
(
e
.
affectsConfiguration
(
'
configurationService.folder.testSetting
'
));
assert
.
equal
(
testObject
.
getValue
(
'
configurationService.folder.testSetting
'
),
'
userValue
'
);
disposable
.
dispose
();
c
();
});
await
fileService
.
del
(
workspaceSettingsResource
);
});
});
});
suite
(
'
WorkspaceConfigurationService-Multiroot
'
,
()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录