Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e1a43609
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,发现更多精彩内容 >>
提交
e1a43609
编写于
3月 19, 2017
作者:
K
katainaka0503
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename autoDetectEncoding to autoGuessEncoding
上级
3de68cda
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
26 addition
and
26 deletion
+26
-26
src/vs/base/node/encoding.ts
src/vs/base/node/encoding.ts
+7
-7
src/vs/base/node/mime.ts
src/vs/base/node/mime.ts
+11
-11
src/vs/base/test/node/mime/mime.test.ts
src/vs/base/test/node/mime/mime.test.ts
+1
-1
src/vs/platform/files/common/files.ts
src/vs/platform/files/common/files.ts
+1
-1
src/vs/platform/telemetry/common/telemetryUtils.ts
src/vs/platform/telemetry/common/telemetryUtils.ts
+1
-1
src/vs/workbench/parts/files/browser/files.contribution.ts
src/vs/workbench/parts/files/browser/files.contribution.ts
+2
-2
src/vs/workbench/services/files/electron-browser/fileService.ts
.../workbench/services/files/electron-browser/fileService.ts
+1
-1
src/vs/workbench/services/files/node/fileService.ts
src/vs/workbench/services/files/node/fileService.ts
+2
-2
未找到文件。
src/vs/base/node/encoding.ts
浏览文件 @
e1a43609
...
...
@@ -97,22 +97,22 @@ export function detectEncodingByBOM(file: string): TPromise<string> {
const
IGNORE_ENCODINGS
=
[
'
ascii
'
,
'
utf-8
'
,
'
utf-16
'
,
'
utf-32
'
];
/**
*
Detect
s the encoding from buffer.
*
Guesse
s the encoding from buffer.
*/
export
function
detect
EncodingByBuffer
(
buffer
:
NodeBuffer
):
string
{
let
detect
ed
=
jschardet
.
detect
(
buffer
);
if
(
!
detected
||
!
detect
ed
.
encoding
)
{
export
function
guess
EncodingByBuffer
(
buffer
:
NodeBuffer
):
string
{
let
guess
ed
=
jschardet
.
detect
(
buffer
);
if
(
!
guessed
||
!
guess
ed
.
encoding
)
{
return
null
;
}
let
enc
=
detect
ed
.
encoding
.
toLowerCase
();
let
enc
=
guess
ed
.
encoding
.
toLowerCase
();
// Ignore encodings that cannot
detect
correctly
// Ignore encodings that cannot
guess
correctly
// (http://chardet.readthedocs.io/en/latest/supported-encodings.html)
if
(
0
<=
IGNORE_ENCODINGS
.
indexOf
(
enc
))
{
return
null
;
}
return
detect
ed
.
encoding
;
return
guess
ed
.
encoding
;
}
/**
* The encodings that are allowed in a settings file don't match the canonical encoding labels specified by WHATWG.
...
...
src/vs/base/node/mime.ts
浏览文件 @
e1a43609
...
...
@@ -58,19 +58,19 @@ export interface IMimeAndEncoding {
mimes
:
string
[];
}
function
doDetectMimesFromStream
(
instream
:
streams
.
Readable
,
auto
Detect
Encoding
:
boolean
):
TPromise
<
IMimeAndEncoding
>
{
function
doDetectMimesFromStream
(
instream
:
streams
.
Readable
,
auto
Guess
Encoding
:
boolean
):
TPromise
<
IMimeAndEncoding
>
{
return
stream
.
readExactlyByStream
(
instream
,
BUFFER_READ_MAX_LEN
).
then
((
readResult
:
stream
.
ReadResult
)
=>
{
return
detectMimeAndEncodingFromBuffer
(
readResult
,
auto
Detect
Encoding
);
return
detectMimeAndEncodingFromBuffer
(
readResult
,
auto
Guess
Encoding
);
});
}
function
doDetectMimesFromFile
(
absolutePath
:
string
,
auto
Detect
Encoding
:
boolean
):
TPromise
<
IMimeAndEncoding
>
{
function
doDetectMimesFromFile
(
absolutePath
:
string
,
auto
Guess
Encoding
:
boolean
):
TPromise
<
IMimeAndEncoding
>
{
return
stream
.
readExactlyByFile
(
absolutePath
,
BUFFER_READ_MAX_LEN
).
then
((
readResult
:
stream
.
ReadResult
)
=>
{
return
detectMimeAndEncodingFromBuffer
(
readResult
,
auto
Detect
Encoding
);
return
detectMimeAndEncodingFromBuffer
(
readResult
,
auto
Guess
Encoding
);
});
}
export
function
detectMimeAndEncodingFromBuffer
({
buffer
,
bytesRead
}:
stream
.
ReadResult
,
autoDetect
Encoding
:
boolean
):
IMimeAndEncoding
{
export
function
detectMimeAndEncodingFromBuffer
({
buffer
,
bytesRead
}:
stream
.
ReadResult
,
autoGuess
Encoding
:
boolean
):
IMimeAndEncoding
{
let
enc
=
encoding
.
detectEncodingByBOMFromBuffer
(
buffer
,
bytesRead
);
// Detect 0 bytes to see if file is binary (ignore for UTF 16 though)
...
...
@@ -83,8 +83,8 @@ export function detectMimeAndEncodingFromBuffer({buffer, bytesRead}: stream.Read
}
}
}
if
(
auto
Detect
Encoding
&&
isText
&&
!
enc
)
{
enc
=
encoding
.
detect
EncodingByBuffer
(
buffer
);
if
(
auto
Guess
Encoding
&&
isText
&&
!
enc
)
{
enc
=
encoding
.
guess
EncodingByBuffer
(
buffer
);
}
return
{
...
...
@@ -123,8 +123,8 @@ function filterAndSortMimes(detectedMimes: string[], guessedMimes: string[]): st
* @param instream the readable stream to detect the mime types from.
* @param nameHint an additional hint that can be used to detect a mime from a file extension.
*/
export
function
detectMimesFromStream
(
instream
:
streams
.
Readable
,
nameHint
:
string
,
auto
Detect
Encoding
:
boolean
):
TPromise
<
IMimeAndEncoding
>
{
return
doDetectMimesFromStream
(
instream
,
auto
Detect
Encoding
).
then
(
encoding
=>
export
function
detectMimesFromStream
(
instream
:
streams
.
Readable
,
nameHint
:
string
,
auto
Guess
Encoding
:
boolean
):
TPromise
<
IMimeAndEncoding
>
{
return
doDetectMimesFromStream
(
instream
,
auto
Guess
Encoding
).
then
(
encoding
=>
handleMimeResult
(
nameHint
,
encoding
)
);
}
...
...
@@ -133,8 +133,8 @@ export function detectMimesFromStream(instream: streams.Readable, nameHint: stri
* Opens the given file to detect its mime type. Returns an array of mime types sorted from most specific to unspecific.
* @param absolutePath the absolute path of the file.
*/
export
function
detectMimesFromFile
(
absolutePath
:
string
,
auto
Detect
Encoding
:
boolean
):
TPromise
<
IMimeAndEncoding
>
{
return
doDetectMimesFromFile
(
absolutePath
,
auto
Detect
Encoding
).
then
(
encoding
=>
export
function
detectMimesFromFile
(
absolutePath
:
string
,
auto
Guess
Encoding
:
boolean
):
TPromise
<
IMimeAndEncoding
>
{
return
doDetectMimesFromFile
(
absolutePath
,
auto
Guess
Encoding
).
then
(
encoding
=>
handleMimeResult
(
absolutePath
,
encoding
)
);
}
...
...
src/vs/base/test/node/mime/mime.test.ts
浏览文件 @
e1a43609
...
...
@@ -61,7 +61,7 @@ suite('Mime', () => {
},
done
);
});
test
(
'
auto
Detect
Encoding (ShiftJIS)
'
,
function
(
done
:
()
=>
void
)
{
test
(
'
auto
Guess
Encoding (ShiftJIS)
'
,
function
(
done
:
()
=>
void
)
{
const
file
=
require
.
toUrl
(
'
./fixtures/some.shiftjis.txt
'
);
mime
.
detectMimesFromFile
(
file
,
true
).
then
(
mimes
=>
{
assert
.
deepEqual
(
mimes
.
encoding
,
'
SHIFT_JIS
'
);
...
...
src/vs/platform/files/common/files.ts
浏览文件 @
e1a43609
...
...
@@ -575,7 +575,7 @@ export interface IFilesConfiguration {
exclude
:
glob
.
IExpression
;
watcherExclude
:
{
[
filepattern
:
string
]:
boolean
};
encoding
:
string
;
auto
Detect
Encoding
:
boolean
;
auto
Guess
Encoding
:
boolean
;
trimTrailingWhitespace
:
boolean
;
autoSave
:
string
;
autoSaveDelay
:
number
;
...
...
src/vs/platform/telemetry/common/telemetryUtils.ts
浏览文件 @
e1a43609
...
...
@@ -240,7 +240,7 @@ const configurationValueWhitelist = [
'
editor.acceptSuggestionOnCommitCharacter
'
,
'
workbench.editor.showTabs
'
,
'
files.encoding
'
,
'
files.auto
Detect
Encoding
'
,
'
files.auto
Guess
Encoding
'
,
'
editor.quickSuggestionsDelay
'
,
'
editor.snippetSuggestions
'
,
'
editor.selectionHighlight
'
,
...
...
src/vs/workbench/parts/files/browser/files.contribution.ts
浏览文件 @
e1a43609
...
...
@@ -212,10 +212,10 @@ configurationRegistry.registerConfiguration({
'
default
'
:
'
utf8
'
,
'
description
'
:
nls
.
localize
(
'
encoding
'
,
"
The default character set encoding to use when reading and writing files.
"
),
},
'
files.auto
Detect
Encoding
'
:
{
'
files.auto
Guess
Encoding
'
:
{
'
type
'
:
'
boolean
'
,
'
default
'
:
false
,
'
description
'
:
nls
.
localize
(
'
auto
DetetEncoding
'
,
"
whem enabled, will use detected encoding in opening a text file.
"
)
'
description
'
:
nls
.
localize
(
'
auto
GuessEncoding
'
,
"
When enabled, will attempt to guess the character set encoding when opening files
"
)
},
'
files.eol
'
:
{
'
type
'
:
'
string
'
,
...
...
src/vs/workbench/services/files/electron-browser/fileService.ts
浏览文件 @
e1a43609
...
...
@@ -81,7 +81,7 @@ export class FileService implements IFileService {
const
fileServiceConfig
:
IFileServiceOptions
=
{
errorLogger
:
(
msg
:
string
)
=>
this
.
onFileServiceError
(
msg
),
encoding
:
configuration
.
files
&&
configuration
.
files
.
encoding
,
auto
DetectEncoding
:
configuration
.
files
&&
configuration
.
files
.
autoDetect
Encoding
,
auto
GuessEncoding
:
configuration
.
files
&&
configuration
.
files
.
autoGuess
Encoding
,
encodingOverride
,
watcherIgnoredPatterns
,
verboseLogging
:
environmentService
.
verbose
,
...
...
src/vs/workbench/services/files/node/fileService.ts
浏览文件 @
e1a43609
...
...
@@ -44,7 +44,7 @@ export interface IFileServiceOptions {
tmpDir
?:
string
;
errorLogger
?:
(
msg
:
string
)
=>
void
;
encoding
?:
string
;
auto
Detect
Encoding
?:
boolean
;
auto
Guess
Encoding
?:
boolean
;
bom
?:
string
;
encodingOverride
?:
IEncodingOverride
[];
watcherIgnoredPatterns
?:
string
[];
...
...
@@ -206,7 +206,7 @@ export class FileService implements IFileService {
}
// 2.) detect mimes
return
mime
.
detectMimesFromFile
(
absolutePath
,
this
.
options
.
auto
Detect
Encoding
).
then
((
detected
:
mime
.
IMimeAndEncoding
)
=>
{
return
mime
.
detectMimesFromFile
(
absolutePath
,
this
.
options
.
auto
Guess
Encoding
).
then
((
detected
:
mime
.
IMimeAndEncoding
)
=>
{
const
isText
=
detected
.
mimes
.
indexOf
(
baseMime
.
MIME_BINARY
)
===
-
1
;
// Return error early if client only accepts text and this is not text
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录