Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ffe5db3e
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,发现更多精彩内容 >>
提交
ffe5db3e
编写于
4月 13, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
files2 - textfile.read()
上级
dac2e270
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
42 addition
and
29 deletion
+42
-29
src/vs/workbench/contrib/files/common/files.ts
src/vs/workbench/contrib/files/common/files.ts
+1
-1
src/vs/workbench/contrib/welcome/walkThrough/common/walkThroughContentProvider.ts
.../welcome/walkThrough/common/walkThroughContentProvider.ts
+2
-2
src/vs/workbench/services/textfile/browser/textFileService.ts
...vs/workbench/services/textfile/browser/textFileService.ts
+20
-0
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
...workbench/services/textfile/common/textFileEditorModel.ts
+1
-1
src/vs/workbench/services/textfile/common/textFileService.ts
src/vs/workbench/services/textfile/common/textFileService.ts
+4
-8
src/vs/workbench/services/textfile/common/textfiles.ts
src/vs/workbench/services/textfile/common/textfiles.ts
+2
-2
src/vs/workbench/services/textfile/test/textFileService.io.test.ts
...rkbench/services/textfile/test/textFileService.io.test.ts
+8
-8
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+3
-3
src/vs/workbench/workbench.nodeless.main.ts
src/vs/workbench/workbench.nodeless.main.ts
+1
-4
未找到文件。
src/vs/workbench/contrib/files/common/files.ts
浏览文件 @
ffe5db3e
...
...
@@ -176,7 +176,7 @@ export class FileOnDiskContentProvider implements ITextModelContentProvider {
private
resolveEditorModel
(
resource
:
URI
,
createAsNeeded
:
boolean
=
true
):
Promise
<
ITextModel
|
null
>
{
const
savedFileResource
=
toLocalResource
(
resource
,
this
.
environmentService
.
configuration
.
remoteAuthority
);
return
this
.
textFileService
.
re
solve
(
savedFileResource
).
then
(
content
=>
{
return
this
.
textFileService
.
re
ad
(
savedFileResource
).
then
(
content
=>
{
let
codeEditorModel
=
this
.
modelService
.
getModel
(
resource
);
if
(
codeEditorModel
)
{
this
.
modelService
.
updateModel
(
codeEditorModel
,
content
.
value
);
...
...
src/vs/workbench/contrib/welcome/walkThrough/common/walkThroughContentProvider.ts
浏览文件 @
ffe5db3e
...
...
@@ -35,7 +35,7 @@ export class WalkThroughContentProvider implements ITextModelContentProvider, IW
reject
(
err
);
}
});
})
:
this
.
textFileService
.
re
solve
(
URI
.
file
(
resource
.
fsPath
)).
then
(
content
=>
content
.
value
));
})
:
this
.
textFileService
.
re
ad
(
URI
.
file
(
resource
.
fsPath
)).
then
(
content
=>
content
.
value
));
return
content
.
then
(
content
=>
{
let
codeEditorModel
=
this
.
modelService
.
getModel
(
resource
);
if
(
!
codeEditorModel
)
{
...
...
@@ -61,7 +61,7 @@ export class WalkThroughSnippetContentProvider implements ITextModelContentProvi
}
public
provideTextContent
(
resource
:
URI
):
Promise
<
ITextModel
>
{
return
this
.
textFileService
.
re
solve
(
URI
.
file
(
resource
.
fsPath
)).
then
(
content
=>
{
return
this
.
textFileService
.
re
ad
(
URI
.
file
(
resource
.
fsPath
)).
then
(
content
=>
{
let
codeEditorModel
=
this
.
modelService
.
getModel
(
resource
);
if
(
!
codeEditorModel
)
{
const
j
=
parseInt
(
resource
.
fragment
);
...
...
src/vs/workbench/services/textfile/browser/textFileService.ts
0 → 100644
浏览文件 @
ffe5db3e
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
TextFileService
}
from
'
vs/workbench/services/textfile/common/textFileService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IResourceEncodings
,
IResourceEncoding
}
from
'
vs/platform/files/common/files
'
;
export
class
BrowserTextFileService
extends
TextFileService
{
readonly
encoding
:
IResourceEncodings
=
{
getPreferredWriteEncoding
():
IResourceEncoding
{
return
{
encoding
:
'
utf8
'
,
hasBOM
:
false
};
}
};
}
registerSingleton
(
ITextFileService
,
BrowserTextFileService
);
\ No newline at end of file
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
浏览文件 @
ffe5db3e
...
...
@@ -306,7 +306,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
// Resolve Content
try
{
const
content
=
await
this
.
textFileService
.
re
solve
(
this
.
resource
,
{
acceptTextOnly
:
!
allowBinary
,
etag
,
encoding
:
this
.
preferredEncoding
});
const
content
=
await
this
.
textFileService
.
re
ad
(
this
.
resource
,
{
acceptTextOnly
:
!
allowBinary
,
etag
,
encoding
:
this
.
preferredEncoding
});
// Clear orphaned state when loading was successful
this
.
setOrphaned
(
false
);
...
...
src/vs/workbench/services/textfile/common/textFileService.ts
浏览文件 @
ffe5db3e
...
...
@@ -15,7 +15,7 @@ import { IResult, ITextFileOperationResult, ITextFileService, IRawTextContent, I
import
{
ConfirmResult
,
IRevertOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
ILifecycleService
,
ShutdownReason
,
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IWorkspaceContextService
,
WorkbenchState
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IFileService
,
IResolveContentOptions
,
IFilesConfiguration
,
FileOperationError
,
FileOperationResult
,
AutoSaveConfiguration
,
HotExitConfiguration
,
ITextSnapshot
,
IWriteTextFileOptions
,
IFileStatWithMetadata
,
toBufferOrReadable
,
ICreateFileOptions
,
IResourceEncodings
,
IResourceEncoding
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileService
,
IResolveContentOptions
,
IFilesConfiguration
,
FileOperationError
,
FileOperationResult
,
AutoSaveConfiguration
,
HotExitConfiguration
,
ITextSnapshot
,
IWriteTextFileOptions
,
IFileStatWithMetadata
,
toBufferOrReadable
,
ICreateFileOptions
,
IResourceEncodings
}
from
'
vs/platform/files/common/files
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
...
...
@@ -41,7 +41,7 @@ import { trim } from 'vs/base/common/strings';
/**
* The workbench file service implementation implements the raw file service spec and adds additional methods on top.
*/
export
class
TextFileService
extends
Disposable
implements
ITextFileService
{
export
abstract
class
TextFileService
extends
Disposable
implements
ITextFileService
{
_serviceBrand
:
ServiceIdentifier
<
any
>
;
...
...
@@ -57,11 +57,7 @@ export class TextFileService extends Disposable implements ITextFileService {
private
_models
:
TextFileEditorModelManager
;
get
models
():
ITextFileEditorModelManager
{
return
this
.
_models
;
}
readonly
encoding
:
IResourceEncodings
=
{
getPreferredWriteEncoding
():
IResourceEncoding
{
return
{
encoding
:
'
utf8
'
,
hasBOM
:
false
};
}
};
abstract
get
encoding
():
IResourceEncodings
;
private
currentFilesAssociationConfig
:
{
[
key
:
string
]:
string
;
};
private
configuredAutoSaveDelay
?:
number
;
...
...
@@ -372,7 +368,7 @@ export class TextFileService extends Disposable implements ITextFileService {
//#region primitives (resolve, create, move, delete, update)
async
re
solve
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
Promise
<
IRawTextContent
>
{
async
re
ad
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
Promise
<
IRawTextContent
>
{
const
streamContent
=
await
this
.
fileService
.
resolveStreamContent
(
resource
,
options
);
const
value
=
await
createTextBufferFactoryFromStream
(
streamContent
.
value
);
...
...
src/vs/workbench/services/textfile/common/textfiles.ts
浏览文件 @
ffe5db3e
...
...
@@ -355,9 +355,9 @@ export interface ITextFileService extends IDisposable {
create
(
resource
:
URI
,
contents
?:
string
|
ITextSnapshot
,
options
?:
{
overwrite
?:
boolean
}):
Promise
<
IFileStatWithMetadata
>
;
/**
* Re
solve
the contents of a file identified by the resource.
* Re
ad
the contents of a file identified by the resource.
*/
re
solve
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
Promise
<
IRawTextContent
>
;
re
ad
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
Promise
<
IRawTextContent
>
;
/**
* Update a file with given contents.
...
...
src/vs/workbench/services/textfile/test/textFileService.io.test.ts
浏览文件 @
ffe5db3e
...
...
@@ -246,7 +246,7 @@ suite('Files - TextFileService i/o', () => {
const
detectedEncoding
=
await
detectEncodingByBOM
(
resource
.
fsPath
);
assert
.
equal
(
detectedEncoding
,
encoding
);
const
resolved
=
await
service
.
re
solve
(
resource
);
const
resolved
=
await
service
.
re
ad
(
resource
);
assert
.
equal
(
resolved
.
encoding
,
encoding
);
assert
.
equal
(
snapshotToString
(
resolved
.
value
.
create
(
isWindows
?
DefaultEndOfLine
.
CRLF
:
DefaultEndOfLine
.
LF
).
createSnapshot
(
false
)),
expectedContent
);
...
...
@@ -273,18 +273,18 @@ suite('Files - TextFileService i/o', () => {
});
async
function
testEncodingKeepsData
(
resource
:
URI
,
encoding
:
string
,
expected
:
string
)
{
let
resolved
=
await
service
.
re
solve
(
resource
,
{
encoding
});
let
resolved
=
await
service
.
re
ad
(
resource
,
{
encoding
});
const
content
=
snapshotToString
(
resolved
.
value
.
create
(
isWindows
?
DefaultEndOfLine
.
CRLF
:
DefaultEndOfLine
.
LF
).
createSnapshot
(
false
));
assert
.
equal
(
content
,
expected
);
await
service
.
write
(
resource
,
content
,
{
encoding
});
resolved
=
await
service
.
re
solve
(
resource
,
{
encoding
});
resolved
=
await
service
.
re
ad
(
resource
,
{
encoding
});
assert
.
equal
(
snapshotToString
(
resolved
.
value
.
create
(
DefaultEndOfLine
.
CRLF
).
createSnapshot
(
false
)),
content
);
await
service
.
write
(
resource
,
TextModel
.
createFromString
(
content
).
createSnapshot
(),
{
encoding
});
resolved
=
await
service
.
re
solve
(
resource
,
{
encoding
});
resolved
=
await
service
.
re
ad
(
resource
,
{
encoding
});
assert
.
equal
(
snapshotToString
(
resolved
.
value
.
create
(
DefaultEndOfLine
.
CRLF
).
createSnapshot
(
false
)),
content
);
}
...
...
@@ -295,7 +295,7 @@ suite('Files - TextFileService i/o', () => {
await
service
.
write
(
resource
,
content
);
const
resolved
=
await
service
.
re
solve
(
resource
);
const
resolved
=
await
service
.
re
ad
(
resource
);
assert
.
equal
(
snapshotToString
(
resolved
.
value
.
create
(
isWindows
?
DefaultEndOfLine
.
CRLF
:
DefaultEndOfLine
.
LF
).
createSnapshot
(
false
)),
content
);
});
...
...
@@ -306,14 +306,14 @@ suite('Files - TextFileService i/o', () => {
await
service
.
write
(
resource
,
TextModel
.
createFromString
(
content
).
createSnapshot
());
const
resolved
=
await
service
.
re
solve
(
resource
);
const
resolved
=
await
service
.
re
ad
(
resource
);
assert
.
equal
(
snapshotToString
(
resolved
.
value
.
create
(
isWindows
?
DefaultEndOfLine
.
CRLF
:
DefaultEndOfLine
.
LF
).
createSnapshot
(
false
)),
content
);
});
test
(
'
write - encoding preserved (UTF 16 LE) - content as string
'
,
async
()
=>
{
const
resource
=
URI
.
file
(
join
(
testDir
,
'
some_utf16le.css
'
));
const
resolved
=
await
service
.
re
solve
(
resource
);
const
resolved
=
await
service
.
re
ad
(
resource
);
assert
.
equal
(
resolved
.
encoding
,
UTF16le
);
await
testEncoding
(
URI
.
file
(
join
(
testDir
,
'
some_utf16le.css
'
)),
UTF16le
,
'
Hello
\n
World
'
,
'
Hello
\n
World
'
);
...
...
@@ -322,7 +322,7 @@ suite('Files - TextFileService i/o', () => {
test
(
'
write - encoding preserved (UTF 16 LE) - content as snapshot
'
,
async
()
=>
{
const
resource
=
URI
.
file
(
join
(
testDir
,
'
some_utf16le.css
'
));
const
resolved
=
await
service
.
re
solve
(
resource
);
const
resolved
=
await
service
.
re
ad
(
resource
);
assert
.
equal
(
resolved
.
encoding
,
UTF16le
);
await
testEncoding
(
URI
.
file
(
join
(
testDir
,
'
some_utf16le.css
'
)),
UTF16le
,
TextModel
.
createFromString
(
'
Hello
\n
World
'
).
createSnapshot
(),
'
Hello
\n
World
'
);
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
ffe5db3e
...
...
@@ -25,7 +25,6 @@ import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/serv
import
{
IWorkspaceContextService
,
IWorkspace
as
IWorkbenchWorkspace
,
WorkbenchState
,
IWorkspaceFolder
,
IWorkspaceFoldersChangeEvent
,
Workspace
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ILifecycleService
,
BeforeShutdownEvent
,
ShutdownReason
,
StartupKind
,
LifecyclePhase
,
WillShutdownEvent
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
TextFileService
}
from
'
vs/workbench/services/textfile/common/textFileService
'
;
import
{
FileOperationEvent
,
IFileService
,
IResolveContentOptions
,
FileOperationError
,
IFileStat
,
IResolveFileResult
,
FileChangesEvent
,
IResolveFileOptions
,
IContent
,
IStreamContent
,
ICreateFileOptions
,
ITextSnapshot
,
IResourceEncoding
,
IFileSystemProvider
,
FileSystemProviderCapabilities
,
IFileChange
,
IWatchOptions
,
IStat
,
FileType
,
FileDeleteOptions
,
FileOverwriteOptions
,
FileWriteOptions
,
FileOpenOptions
,
IFileStatWithMetadata
,
IResolveMetadataFileOptions
,
IWriteFileOptions
}
from
'
vs/platform/files/common/files
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
ModeServiceImpl
}
from
'
vs/editor/common/services/modeServiceImpl
'
;
...
...
@@ -83,6 +82,7 @@ import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedPr
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
WorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/node/environmentService
'
;
import
{
VSBuffer
,
VSBufferReadable
}
from
'
vs/base/common/buffer
'
;
import
{
BrowserTextFileService
}
from
'
vs/workbench/services/textfile/browser/textFileService
'
;
export
function
createFileInput
(
instantiationService
:
IInstantiationService
,
resource
:
URI
):
FileEditorInput
{
return
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
undefined
);
...
...
@@ -176,7 +176,7 @@ export class TestContextService implements IWorkspaceContextService {
}
}
export
class
TestTextFileService
extends
TextFileService
{
export
class
TestTextFileService
extends
Browser
TextFileService
{
public
cleanupBackupsBeforeShutdownCalled
:
boolean
;
private
promptPath
:
URI
;
...
...
@@ -235,7 +235,7 @@ export class TestTextFileService extends TextFileService {
this
.
resolveTextContentError
=
error
;
}
public
re
solve
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
Promise
<
IRawTextContent
>
{
public
re
ad
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
Promise
<
IRawTextContent
>
{
if
(
this
.
resolveTextContentError
)
{
const
error
=
this
.
resolveTextContentError
;
this
.
resolveTextContentError
=
null
;
...
...
src/vs/workbench/workbench.nodeless.main.ts
浏览文件 @
ffe5db3e
...
...
@@ -91,8 +91,6 @@ import { ContextViewService } from 'vs/platform/contextview/browser/contextViewS
// import { RelayURLService } from 'vs/platform/url/electron-browser/urlService';
import
{
IHeapService
,
NullHeapService
}
from
'
vs/workbench/services/heap/common/heap
'
;
import
{
IBroadcastService
,
NullBroadcastService
}
from
'
vs/workbench/services/broadcast/common/broadcast
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
TextFileService
}
from
'
vs/workbench/services/textfile/common/textFileService
'
;
import
{
ConfigurationResolverService
}
from
'
vs/workbench/services/configurationResolver/browser/configurationResolverService
'
;
import
{
IConfigurationResolverService
}
from
'
vs/workbench/services/configurationResolver/common/configurationResolver
'
;
...
...
@@ -115,7 +113,7 @@ import 'vs/workbench/services/preferences/browser/preferencesService';
import
'
vs/workbench/services/output/common/outputChannelModelService
'
;
import
'
vs/workbench/services/configuration/common/jsonEditingService
'
;
import
'
vs/workbench/services/textmodelResolver/common/textModelResolverService
'
;
// import 'vs/workbench/services/textfile/node
/textFileService';
import
'
vs/workbench/services/textfile/browser
/textFileService
'
;
import
'
vs/workbench/services/dialogs/browser/fileDialogService
'
;
// import 'vs/workbench/services/dialogs/electron-browser/dialogService';
// import 'vs/workbench/services/backup/node/backupFileService';
...
...
@@ -171,7 +169,6 @@ registerSingleton(IContextViewService, ContextViewService, true);
registerSingleton
(
IHeapService
,
NullHeapService
);
registerSingleton
(
IBroadcastService
,
NullBroadcastService
);
registerSingleton
(
IContextMenuService
,
ContextMenuService
);
registerSingleton
(
ITextFileService
,
TextFileService
);
registerSingleton
(
IConfigurationResolverService
,
ConfigurationResolverService
,
true
);
//#endregion
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录