Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a744e4e1
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,发现更多精彩内容 >>
提交
a744e4e1
编写于
10月 30, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - workspace settings only supports specific files
上级
9f1f36cb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
47 deletion
+37
-47
src/vs/workbench/services/configuration/common/configuration.ts
.../workbench/services/configuration/common/configuration.ts
+6
-1
src/vs/workbench/services/configuration/common/model.ts
src/vs/workbench/services/configuration/common/model.ts
+4
-7
src/vs/workbench/services/configuration/node/configurationEditingService.ts
...ervices/configuration/node/configurationEditingService.ts
+1
-6
src/vs/workbench/services/configuration/node/configurationService.ts
...bench/services/configuration/node/configurationService.ts
+24
-10
src/vs/workbench/services/configuration/test/common/model.test.ts
...orkbench/services/configuration/test/common/model.test.ts
+0
-22
src/vs/workbench/services/configuration/test/node/configurationEditingService.test.ts
...nfiguration/test/node/configurationEditingService.test.ts
+2
-1
未找到文件。
src/vs/workbench/services/configuration/common/configuration.ts
浏览文件 @
a744e4e1
...
...
@@ -27,4 +27,9 @@ export interface IWorkspaceConfigurationService extends IConfigurationService {
export
interface
IWorkspaceConfigurationValue
<
T
>
extends
IConfigurationValue
<
T
>
{
workspace
:
T
;
}
\ No newline at end of file
}
export
const
WORKSPACE_STANDALONE_CONFIGURATIONS
=
{
'
tasks
'
:
'
.vscode/tasks.json
'
,
'
launch
'
:
'
.vscode/launch.json
'
};
\ No newline at end of file
src/vs/workbench/services/configuration/common/model.ts
浏览文件 @
a744e4e1
...
...
@@ -51,7 +51,7 @@ export function merge(base: any, add: any, overwrite: boolean): void {
export
function
consolidate
(
configMap
:
{
[
key
:
string
]:
IConfigFile
;
}):
{
contents
:
any
;
parseErrors
:
string
[];
}
{
const
finalConfig
:
any
=
Object
.
create
(
null
);
const
parseErrors
:
string
[]
=
[];
const
regexp
=
/
\/(
team
\.)?(
[^\.]
*
)
*
\.
json/
;
const
regexp
=
/
\/([^\.]
*
)
*
\.
json/
;
// We want to use the default settings file as base and let all other config
// files overwrite the base one
...
...
@@ -69,15 +69,12 @@ export function consolidate(configMap: { [key: string]: IConfigFile; }): { conte
return
;
}
// If a file is team.foo.json, it indicates team settings, strip this away
const
isTeamSetting
=
!!
matches
[
1
];
// Extract the config key from the file name (except for settings.json which is the default)
let
configElement
:
any
=
finalConfig
;
if
(
matches
&&
matches
[
2
]
&&
matches
[
2
]
!==
CONFIG_DEFAULT_NAME
)
{
if
(
matches
&&
matches
[
1
]
&&
matches
[
1
]
!==
CONFIG_DEFAULT_NAME
)
{
// Use the name of the file as top level config section for all settings inside
const
configSection
=
matches
[
2
];
const
configSection
=
matches
[
1
];
let
element
=
configElement
[
configSection
];
if
(
!
element
)
{
element
=
Object
.
create
(
null
);
...
...
@@ -86,7 +83,7 @@ export function consolidate(configMap: { [key: string]: IConfigFile; }): { conte
configElement
=
element
;
}
merge
(
configElement
,
config
.
contents
,
!
isTeamSetting
/* user settings overrule team settings */
);
merge
(
configElement
,
config
.
contents
,
false
);
if
(
config
.
parseError
)
{
parseErrors
.
push
(
configFileName
);
}
...
...
src/vs/workbench/services/configuration/node/configurationEditingService.ts
浏览文件 @
a744e4e1
...
...
@@ -19,15 +19,10 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
WORKSPACE_CONFIG_DEFAULT_PATH
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
WORKSPACE_CONFIG_DEFAULT_PATH
,
WORKSPACE_STANDALONE_CONFIGURATIONS
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IConfigurationEditingService
,
ConfigurationEditingErrorCode
,
IConfigurationEditingError
,
ConfigurationTarget
,
IConfigurationValue
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
export
const
WORKSPACE_STANDALONE_CONFIGURATIONS
=
{
'
tasks
'
:
'
.vscode/tasks.json
'
,
'
launch
'
:
'
.vscode/launch.json
'
};
interface
IConfigurationEditOperation
extends
IConfigurationValue
{
target
:
URI
;
isWorkspaceStandalone
?:
boolean
;
...
...
src/vs/workbench/services/configuration/node/configurationService.ts
浏览文件 @
a744e4e1
...
...
@@ -21,7 +21,7 @@ import errors = require('vs/base/common/errors');
import
{
IConfigFile
,
consolidate
,
newConfigFile
}
from
'
vs/workbench/services/configuration/common/model
'
;
import
{
IConfigurationServiceEvent
,
getConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ConfigurationService
as
BaseConfigurationService
}
from
'
vs/platform/configuration/node/configurationService
'
;
import
{
IWorkspaceConfigurationService
,
IWorkspaceConfigurationValue
,
CONFIG_DEFAULT_NAME
,
WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IWorkspaceConfigurationService
,
IWorkspaceConfigurationValue
,
CONFIG_DEFAULT_NAME
,
WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME
,
WORKSPACE_STANDALONE_CONFIGURATIONS
,
WORKSPACE_CONFIG_DEFAULT_PATH
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
EventType
as
FileEventType
,
FileChangeType
,
FileChangesEvent
}
from
'
vs/platform/files/common/files
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
...
...
@@ -172,14 +172,21 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
return
TPromise
.
as
(
Object
.
create
(
null
));
}
// once: when invoked for the first time we fetch
*all* json files using the bulk stats and content route
s
// once: when invoked for the first time we fetch
json files that contribute setting
s
if
(
!
this
.
bulkFetchFromWorkspacePromise
)
{
this
.
bulkFetchFromWorkspacePromise
=
resolveStat
(
this
.
contextService
.
toResource
(
this
.
workspaceSettingsRootFolder
)).
then
(
stat
=>
{
if
(
!
stat
.
isDirectory
)
{
return
TPromise
.
as
([]);
}
return
resolveContents
(
stat
.
children
.
filter
(
stat
=>
paths
.
extname
(
stat
.
resource
.
fsPath
)
===
'
.json
'
).
map
(
stat
=>
stat
.
resource
));
return
resolveContents
(
stat
.
children
.
filter
(
stat
=>
{
const
isJson
=
paths
.
extname
(
stat
.
resource
.
fsPath
)
===
'
.json
'
;
if
(
!
isJson
)
{
return
false
;
// only JSON files
}
return
this
.
isWorkspaceConfigurationFile
(
this
.
contextService
.
toWorkspaceRelativePath
(
stat
.
resource
));
// only workspace config files
}).
map
(
stat
=>
stat
.
resource
));
},
(
err
)
=>
{
if
(
err
)
{
return
[];
// never fail this call
...
...
@@ -200,7 +207,13 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
// Find changes that affect workspace configuration files
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
const
workspacePath
=
this
.
contextService
.
toWorkspaceRelativePath
(
events
[
i
].
resource
);
const
resource
=
events
[
i
].
resource
;
const
isJson
=
paths
.
extname
(
resource
.
fsPath
)
===
'
.json
'
;
if
(
!
isJson
)
{
continue
;
// only JSON files
}
const
workspacePath
=
this
.
contextService
.
toWorkspaceRelativePath
(
resource
);
if
(
!
workspacePath
)
{
continue
;
// event is not inside workspace
}
...
...
@@ -211,11 +224,8 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
affectedByChanges
=
true
;
}
// outside my folder or not a *.json file
if
(
paths
.
extname
(
workspacePath
)
!==
'
.json
'
||
// we only care about *.json files
paths
.
dirname
(
workspacePath
)
!==
this
.
workspaceSettingsRootFolder
// which are top level in .vscode
)
{
// only valid workspace config files
if
(
!
this
.
isWorkspaceConfigurationFile
(
workspacePath
))
{
continue
;
}
...
...
@@ -227,7 +237,7 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
break
;
case
FileChangeType
.
UPDATED
:
case
FileChangeType
.
ADDED
:
this
.
workspaceFilePathToConfiguration
[
workspacePath
]
=
resolveContent
(
events
[
i
].
resource
).
then
(
content
=>
newConfigFile
(
content
.
value
),
errors
.
onUnexpectedError
);
this
.
workspaceFilePathToConfiguration
[
workspacePath
]
=
resolveContent
(
resource
).
then
(
content
=>
newConfigFile
(
content
.
value
),
errors
.
onUnexpectedError
);
affectedByChanges
=
true
;
}
}
...
...
@@ -238,6 +248,10 @@ export class WorkspaceConfigurationService implements IWorkspaceConfigurationSer
}
}
private
isWorkspaceConfigurationFile
(
workspaceRelativePath
:
string
):
boolean
{
return
[
WORKSPACE_CONFIG_DEFAULT_PATH
,
WORKSPACE_STANDALONE_CONFIGURATIONS
.
launch
,
WORKSPACE_STANDALONE_CONFIGURATIONS
.
tasks
].
some
(
p
=>
p
===
workspaceRelativePath
);
}
public
set
telemetryService
(
value
:
ITelemetryService
)
{
this
.
baseConfigurationService
.
telemetryService
=
value
;
}
...
...
src/vs/workbench/services/configuration/test/common/model.test.ts
浏览文件 @
a744e4e1
...
...
@@ -24,28 +24,6 @@ suite('ConfigurationService - Model', () => {
assert
.
deepEqual
(
base
,
{
'
a
'
:
{
'
b
'
:
2
}
});
});
test
(
'
Test consolidate (settings)
'
,
()
=>
{
const
config1
:
model
.
IConfigFile
=
{
contents
:
{
awesome
:
true
}
};
const
config2
:
model
.
IConfigFile
=
{
contents
:
{
awesome
:
false
}
};
const
expected
=
{
awesome
:
false
};
assert
.
deepEqual
(
model
.
consolidate
({
'
.vscode/team.settings.json
'
:
config1
,
'
.vscode/settings.json
'
:
config2
}).
contents
,
expected
);
assert
.
deepEqual
(
model
.
consolidate
({
'
settings.json
'
:
config2
,
'
team.settings.json
'
:
config1
}).
contents
,
{});
assert
.
deepEqual
(
model
.
consolidate
({
'
.vscode/team.settings.json
'
:
config1
,
'
.vscode/settings.json
'
:
config2
,
'
.vscode/team2.settings.json
'
:
config1
}).
contents
,
expected
);
});
test
(
'
Test consolidate (settings and tasks)
'
,
()
=>
{
const
settingsConfig
:
model
.
IConfigFile
=
{
contents
:
{
...
...
src/vs/workbench/services/configuration/test/node/configurationEditingService.test.ts
浏览文件 @
a744e4e1
...
...
@@ -23,12 +23,13 @@ import { WorkspaceConfigurationService } from 'vs/workbench/services/configurati
import
URI
from
'
vs/base/common/uri
'
;
import
utils
=
require
(
'
vs/workbench/services/files/test/node/utils
'
);
import
{
FileService
}
from
'
vs/workbench/services/files/node/fileService
'
;
import
{
ConfigurationEditingService
,
WORKSPACE_STANDALONE_CONFIGURATIONS
}
from
'
vs/workbench/services/configuration/node/configurationEditingService
'
;
import
{
ConfigurationEditingService
}
from
'
vs/workbench/services/configuration/node/configurationEditingService
'
;
import
{
ConfigurationTarget
,
IConfigurationEditingError
,
ConfigurationEditingErrorCode
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
WORKSPACE_STANDALONE_CONFIGURATIONS
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录