Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d41edee8
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,发现更多精彩内容 >>
提交
d41edee8
编写于
4月 03, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Workspace file: encoding should always be UTF-8 (fixes #46935)
上级
f3b860d4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
58 addition
and
8 deletion
+58
-8
src/vs/workbench/services/files/electron-browser/fileService.ts
.../workbench/services/files/electron-browser/fileService.ts
+10
-2
src/vs/workbench/services/files/node/fileService.ts
src/vs/workbench/services/files/node/fileService.ts
+9
-4
src/vs/workbench/services/files/test/node/fileService.test.ts
...vs/workbench/services/files/test/node/fileService.test.ts
+39
-2
未找到文件。
src/vs/workbench/services/files/electron-browser/fileService.ts
浏览文件 @
d41edee8
...
...
@@ -25,6 +25,7 @@ import { isMacintosh, isWindows } from 'vs/base/common/platform';
import
product
from
'
vs/platform/node/product
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
Severity
,
INotificationService
,
PromptOption
}
from
'
vs/platform/notification/common/notification
'
;
import
{
WORKSPACE_EXTENSION
}
from
'
vs/platform/workspaces/common/workspaces
'
;
export
class
FileService
implements
IFileService
{
...
...
@@ -159,9 +160,16 @@ export class FileService implements IFileService {
private
getEncodingOverrides
():
IEncodingOverride
[]
{
const
encodingOverride
:
IEncodingOverride
[]
=
[];
encodingOverride
.
push
({
resource
:
uri
.
file
(
this
.
environmentService
.
appSettingsHome
),
encoding
:
encoding
.
UTF8
});
// Global settings
encodingOverride
.
push
({
parent
:
uri
.
file
(
this
.
environmentService
.
appSettingsHome
),
encoding
:
encoding
.
UTF8
});
// Workspace files
encodingOverride
.
push
({
extension
:
WORKSPACE_EXTENSION
,
encoding
:
encoding
.
UTF8
});
// Folder Settings
this
.
contextService
.
getWorkspace
().
folders
.
forEach
(
folder
=>
{
encodingOverride
.
push
({
resource
:
uri
.
file
(
paths
.
join
(
folder
.
uri
.
fsPath
,
'
.vscode
'
)),
encoding
:
encoding
.
UTF8
});
encodingOverride
.
push
({
parent
:
uri
.
file
(
paths
.
join
(
folder
.
uri
.
fsPath
,
'
.vscode
'
)),
encoding
:
encoding
.
UTF8
});
});
return
encodingOverride
;
...
...
src/vs/workbench/services/files/node/fileService.ts
浏览文件 @
d41edee8
...
...
@@ -42,7 +42,8 @@ import { Readable } from 'stream';
import
{
Schemas
}
from
'
vs/base/common/network
'
;
export
interface
IEncodingOverride
{
resource
:
uri
;
parent
?:
uri
;
extension
?:
string
;
encoding
:
string
;
}
...
...
@@ -974,9 +975,13 @@ export class FileService implements IFileService {
for
(
let
i
=
0
;
i
<
this
.
options
.
encodingOverride
.
length
;
i
++
)
{
const
override
=
this
.
options
.
encodingOverride
[
i
];
// check if the resource is a child of the resource with override and use
// the provided encoding in that case
if
(
isParent
(
resource
.
fsPath
,
override
.
resource
.
fsPath
,
!
isLinux
/* ignorecase */
))
{
// check if the resource is child of encoding override path
if
(
override
.
parent
&&
isParent
(
resource
.
fsPath
,
override
.
parent
.
fsPath
,
!
isLinux
/* ignorecase */
))
{
return
override
.
encoding
;
}
// check if the resource extension is equal to encoding override
if
(
override
.
extension
&&
paths
.
extname
(
resource
.
fsPath
)
===
`.
${
override
.
extension
}
`
)
{
return
override
.
encoding
;
}
}
...
...
src/vs/workbench/services/files/test/node/fileService.test.ts
浏览文件 @
d41edee8
...
...
@@ -912,7 +912,7 @@ suite('FileService', () => {
},
100
);
});
test
(
'
options - encoding
'
,
function
()
{
test
(
'
options - encoding
override (parent)
'
,
function
()
{
// setup
const
_id
=
uuid
.
generateUuid
();
...
...
@@ -922,7 +922,44 @@ suite('FileService', () => {
return
pfs
.
copy
(
_sourceDir
,
_testDir
).
then
(()
=>
{
const
encodingOverride
:
IEncodingOverride
[]
=
[];
encodingOverride
.
push
({
resource
:
uri
.
file
(
path
.
join
(
testDir
,
'
deep
'
)),
parent
:
uri
.
file
(
path
.
join
(
testDir
,
'
deep
'
)),
encoding
:
'
utf16le
'
});
const
configurationService
=
new
TestConfigurationService
();
configurationService
.
setUserConfiguration
(
'
files
'
,
{
encoding
:
'
windows1252
'
});
const
textResourceConfigurationService
=
new
TestTextResourceConfigurationService
(
configurationService
);
const
_service
=
new
FileService
(
new
TestContextService
(
new
Workspace
(
_testDir
,
_testDir
,
toWorkspaceFolders
([{
path
:
_testDir
}]))),
TestEnvironmentService
,
textResourceConfigurationService
,
configurationService
,
new
TestLifecycleService
(),
{
encodingOverride
,
disableWatcher
:
true
});
return
_service
.
resolveContent
(
uri
.
file
(
path
.
join
(
testDir
,
'
index.html
'
))).
then
(
c
=>
{
assert
.
equal
(
c
.
encoding
,
'
windows1252
'
);
return
_service
.
resolveContent
(
uri
.
file
(
path
.
join
(
testDir
,
'
deep
'
,
'
conway.js
'
))).
then
(
c
=>
{
assert
.
equal
(
c
.
encoding
,
'
utf16le
'
);
// teardown
_service
.
dispose
();
});
});
});
});
test
(
'
options - encoding override (extension)
'
,
function
()
{
// setup
const
_id
=
uuid
.
generateUuid
();
const
_testDir
=
path
.
join
(
parentDir
,
_id
);
const
_sourceDir
=
require
.
toUrl
(
'
./fixtures/service
'
);
return
pfs
.
copy
(
_sourceDir
,
_testDir
).
then
(()
=>
{
const
encodingOverride
:
IEncodingOverride
[]
=
[];
encodingOverride
.
push
({
extension
:
'
js
'
,
encoding
:
'
utf16le
'
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录