Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e3f0a1be
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,发现更多精彩内容 >>
提交
e3f0a1be
编写于
9月 17, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #106934
上级
86ed8976
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
22 deletion
+37
-22
src/vs/workbench/services/configuration/browser/configuration.ts
...workbench/services/configuration/browser/configuration.ts
+20
-21
src/vs/workbench/services/configuration/browser/configurationCache.ts
...ench/services/configuration/browser/configurationCache.ts
+7
-0
src/vs/workbench/services/configuration/common/configuration.ts
.../workbench/services/configuration/common/configuration.ts
+2
-0
src/vs/workbench/services/configuration/electron-browser/configurationCache.ts
...ices/configuration/electron-browser/configurationCache.ts
+7
-0
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
...ration/test/electron-browser/configurationService.test.ts
+1
-1
未找到文件。
src/vs/workbench/services/configuration/browser/configuration.ts
浏览文件 @
e3f0a1be
...
...
@@ -19,7 +19,6 @@ import { WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/w
import
{
ConfigurationScope
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
join
}
from
'
vs/base/common/path
'
;
import
{
equals
}
from
'
vs/base/common/objects
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IConfigurationModel
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
hash
}
from
'
vs/base/common/hash
'
;
...
...
@@ -405,7 +404,7 @@ export class WorkspaceConfiguration extends Disposable {
private
_initialized
:
boolean
=
false
;
get
initialized
():
boolean
{
return
this
.
_initialized
;
}
constructor
(
configurationCache
:
IConfigurationCache
,
private
readonly
configurationCache
:
IConfigurationCache
,
fileService
:
IFileService
)
{
super
();
...
...
@@ -413,18 +412,17 @@ export class WorkspaceConfiguration extends Disposable {
this
.
_workspaceConfiguration
=
this
.
_cachedConfiguration
=
new
CachedWorkspaceConfiguration
(
configurationCache
);
}
async
initialize
(
workspaceIdentifier
:
IWorkspaceIdentifier
):
Promise
<
boolean
>
{
async
initialize
(
workspaceIdentifier
:
IWorkspaceIdentifier
):
Promise
<
void
>
{
this
.
_workspaceIdentifier
=
workspaceIdentifier
;
if
(
!
(
this
.
_workspaceConfiguration
instanceof
FileServiceBasedWorkspaceConfiguration
))
{
if
(
this
.
_workspaceIdentifier
.
configPath
.
scheme
===
Schemas
.
file
)
{
this
.
switch
(
new
FileServiceBasedWorkspaceConfiguration
(
this
.
_fileService
));
if
(
!
this
.
_initialized
)
{
if
(
this
.
configurationCache
.
needsCaching
(
this
.
_workspaceIdentifier
.
configPath
))
{
this
.
_workspaceConfiguration
=
this
.
_cachedConfiguration
;
this
.
waitAndInitialize
(
this
.
_workspaceIdentifier
);
}
else
{
this
.
waitAndSwitch
(
this
.
_workspaceIdentifier
);
this
.
doInitialize
(
new
FileServiceBasedWorkspaceConfiguration
(
this
.
_fileService
)
);
}
}
this
.
_initialized
=
this
.
_workspaceConfiguration
instanceof
FileServiceBasedWorkspaceConfiguration
;
await
this
.
reload
();
return
this
.
initialized
;
}
async
reload
():
Promise
<
void
>
{
...
...
@@ -454,22 +452,22 @@ export class WorkspaceConfiguration extends Disposable {
return
this
.
getConfiguration
();
}
private
async
waitAnd
Switch
(
workspaceIdentifier
:
IWorkspaceIdentifier
):
Promise
<
void
>
{
private
async
waitAnd
Initialize
(
workspaceIdentifier
:
IWorkspaceIdentifier
):
Promise
<
void
>
{
await
whenProviderRegistered
(
workspaceIdentifier
.
configPath
,
this
.
_fileService
);
if
(
!
(
this
.
_workspaceConfiguration
instanceof
FileServiceBasedWorkspaceConfiguration
))
{
const
fileServiceBasedWorkspaceConfiguration
=
this
.
_register
(
new
FileServiceBasedWorkspaceConfiguration
(
this
.
_fileService
));
await
fileServiceBasedWorkspaceConfiguration
.
load
(
workspaceIdentifier
);
this
.
switch
(
fileServiceBasedWorkspaceConfiguration
);
this
.
_initialized
=
true
;
this
.
doInitialize
(
fileServiceBasedWorkspaceConfiguration
);
this
.
onDidWorkspaceConfigurationChange
(
false
);
}
}
private
switch
(
fileServiceBasedWorkspaceConfiguration
:
FileServiceBasedWorkspaceConfiguration
):
void
{
private
doInitialize
(
fileServiceBasedWorkspaceConfiguration
:
FileServiceBasedWorkspaceConfiguration
):
void
{
this
.
_workspaceConfiguration
.
dispose
();
this
.
_workspaceConfigurationChangeDisposable
.
dispose
();
this
.
_workspaceConfiguration
=
this
.
_register
(
fileServiceBasedWorkspaceConfiguration
);
this
.
_workspaceConfigurationChangeDisposable
=
this
.
_register
(
this
.
_workspaceConfiguration
.
onDidChange
(
e
=>
this
.
onDidWorkspaceConfigurationChange
(
true
)));
this
.
_initialized
=
true
;
}
private
async
onDidWorkspaceConfigurationChange
(
reload
:
boolean
):
Promise
<
void
>
{
...
...
@@ -481,7 +479,7 @@ export class WorkspaceConfiguration extends Disposable {
}
private
updateCache
():
Promise
<
void
>
{
if
(
this
.
_workspaceIdentifier
&&
this
.
_workspaceIdentifier
.
configPath
.
scheme
!==
Schemas
.
file
&&
this
.
_workspaceConfiguration
instanceof
FileServiceBasedWorkspaceConfiguration
)
{
if
(
this
.
_workspaceIdentifier
&&
this
.
configurationCache
.
needsCaching
(
this
.
_workspaceIdentifier
.
configPath
)
&&
this
.
_workspaceConfiguration
instanceof
FileServiceBasedWorkspaceConfiguration
)
{
return
this
.
_workspaceConfiguration
.
load
(
this
.
_workspaceIdentifier
)
.
then
(()
=>
this
.
_cachedConfiguration
.
updateWorkspace
(
this
.
_workspaceIdentifier
!
,
this
.
_workspaceConfiguration
.
getConfigurationModel
()));
}
...
...
@@ -722,16 +720,14 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
configFolderRelativePath
:
string
,
private
readonly
workbenchState
:
WorkbenchState
,
fileService
:
IFileService
,
configurationCache
:
IConfigurationCache
private
readonly
configurationCache
:
IConfigurationCache
)
{
super
();
this
.
configurationFolder
=
resources
.
joinPath
(
workspaceFolder
.
uri
,
configFolderRelativePath
);
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
{
this
.
cachedFolderConfiguration
=
new
CachedFolderConfiguration
(
workspaceFolder
.
uri
,
configFolderRelativePath
,
configurationCache
);
if
(
this
.
configurationCache
.
needsCaching
(
workspaceFolder
.
uri
))
{
this
.
folderConfiguration
=
this
.
cachedFolderConfiguration
;
whenProviderRegistered
(
workspaceFolder
.
uri
,
fileService
)
.
then
(()
=>
{
this
.
folderConfiguration
.
dispose
();
...
...
@@ -740,6 +736,9 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
this
.
_register
(
this
.
folderConfiguration
.
onDidChange
(
e
=>
this
.
onDidFolderConfigurationChange
()));
this
.
onDidFolderConfigurationChange
();
});
}
else
{
this
.
folderConfiguration
=
this
.
createFileServiceBasedConfiguration
(
fileService
);
this
.
folderConfigurationDisposable
=
this
.
_register
(
this
.
folderConfiguration
.
onDidChange
(
e
=>
this
.
onDidFolderConfigurationChange
()));
}
}
...
...
@@ -763,7 +762,7 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
}
private
updateCache
():
Promise
<
void
>
{
if
(
this
.
configuration
Folder
.
scheme
!==
Schemas
.
file
&&
this
.
folderConfiguration
instanceof
FileServiceBasedConfiguration
)
{
if
(
this
.
configuration
Cache
.
needsCaching
(
this
.
configurationFolder
)
&&
this
.
folderConfiguration
instanceof
FileServiceBasedConfiguration
)
{
return
this
.
folderConfiguration
.
loadConfiguration
()
.
then
(
configurationModel
=>
this
.
cachedFolderConfiguration
.
updateConfiguration
(
configurationModel
));
}
...
...
src/vs/workbench/services/configuration/browser/configurationCache.ts
浏览文件 @
e3f0a1be
...
...
@@ -4,9 +4,16 @@
*--------------------------------------------------------------------------------------------*/
import
{
IConfigurationCache
,
ConfigurationKey
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
class
ConfigurationCache
implements
IConfigurationCache
{
needsCaching
(
resource
:
URI
):
boolean
{
// Cache all non user data resources
return
resource
.
scheme
!==
Schemas
.
userData
;
}
async
read
(
key
:
ConfigurationKey
):
Promise
<
string
>
{
return
''
;
}
...
...
src/vs/workbench/services/configuration/common/configuration.ts
浏览文件 @
e3f0a1be
...
...
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
ConfigurationScope
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
const
FOLDER_CONFIG_FOLDER_NAME
=
'
.vscode
'
;
export
const
FOLDER_SETTINGS_NAME
=
'
settings
'
;
...
...
@@ -35,6 +36,7 @@ export type ConfigurationKey = { type: 'user' | 'workspaces' | 'folder', key: st
export
interface
IConfigurationCache
{
needsCaching
(
resource
:
URI
):
boolean
;
read
(
key
:
ConfigurationKey
):
Promise
<
string
>
;
write
(
key
:
ConfigurationKey
,
content
:
string
):
Promise
<
void
>
;
remove
(
key
:
ConfigurationKey
):
Promise
<
void
>
;
...
...
src/vs/workbench/services/configuration/electron-browser/configurationCache.ts
浏览文件 @
e3f0a1be
...
...
@@ -7,6 +7,8 @@ import * as pfs from 'vs/base/node/pfs';
import
{
join
}
from
'
vs/base/common/path
'
;
import
{
INativeWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/electron-sandbox/environmentService
'
;
import
{
IConfigurationCache
,
ConfigurationKey
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
export
class
ConfigurationCache
implements
IConfigurationCache
{
...
...
@@ -15,6 +17,11 @@ export class ConfigurationCache implements IConfigurationCache {
constructor
(
private
readonly
environmentService
:
INativeWorkbenchEnvironmentService
)
{
}
needsCaching
(
resource
:
URI
):
boolean
{
// Cache all non native resources
return
!
[
Schemas
.
file
,
Schemas
.
userData
].
includes
(
resource
.
scheme
);
}
read
(
key
:
ConfigurationKey
):
Promise
<
string
>
{
return
this
.
getCachedConfiguration
(
key
).
read
();
}
...
...
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
浏览文件 @
e3f0a1be
...
...
@@ -1891,7 +1891,7 @@ suite('WorkspaceConfigurationService - Remote Folder', () => {
const
fileService
=
new
FileService
(
new
NullLogService
());
fileService
.
registerProvider
(
Schemas
.
file
,
diskFileSystemProvider
);
fileService
.
registerProvider
(
Schemas
.
userData
,
new
FileUserDataProvider
(
environmentService
.
appSettingsHome
,
undefined
,
diskFileSystemProvider
,
environmentService
,
new
NullLogService
()));
const
configurationCache
:
IConfigurationCache
=
{
read
:
()
=>
Promise
.
resolve
(
''
),
write
:
()
=>
Promise
.
resolve
(),
remove
:
()
=>
Promise
.
resolve
()
};
const
configurationCache
:
IConfigurationCache
=
{
read
:
()
=>
Promise
.
resolve
(
''
),
write
:
()
=>
Promise
.
resolve
(),
remove
:
()
=>
Promise
.
resolve
()
,
needsCaching
:
()
=>
false
};
testObject
=
new
WorkspaceService
({
configurationCache
,
remoteAuthority
},
environmentService
,
fileService
,
remoteAgentService
,
new
NullLogService
());
instantiationService
.
stub
(
IWorkspaceContextService
,
testObject
);
instantiationService
.
stub
(
IConfigurationService
,
testObject
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录