Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
abe68eb7
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,发现更多精彩内容 >>
提交
abe68eb7
编写于
2月 18, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
text files - remove some now unused methods
上级
2feb47d2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
8 addition
and
49 deletion
+8
-49
src/vs/workbench/services/textfile/browser/textFileService.ts
...vs/workbench/services/textfile/browser/textFileService.ts
+6
-42
src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts
...ch/services/textfile/common/textFileEditorModelManager.ts
+0
-4
src/vs/workbench/services/textfile/common/textfiles.ts
src/vs/workbench/services/textfile/common/textfiles.ts
+2
-3
未找到文件。
src/vs/workbench/services/textfile/browser/textFileService.ts
浏览文件 @
abe68eb7
...
...
@@ -6,7 +6,7 @@
import
*
as
nls
from
'
vs/nls
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
AsyncEmitter
}
from
'
vs/base/common/event
'
;
import
{
I
Result
,
ITextFileOperationResult
,
ITextFileService
,
ITextFileStreamContent
,
ITextFileEditorModel
,
ITextFileContent
,
IResourceEncodings
,
IReadTextFileOptions
,
IWriteTextFileOptions
,
toBufferOrReadable
,
TextFileOperationError
,
TextFileOperationResult
,
ITextFileSaveOptions
,
ITextFileEditorModelManager
,
TextFileCreateEvent
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
I
TextFileService
,
ITextFileStreamContent
,
ITextFileContent
,
IResourceEncodings
,
IReadTextFileOptions
,
IWriteTextFileOptions
,
toBufferOrReadable
,
TextFileOperationError
,
TextFileOperationResult
,
ITextFileSaveOptions
,
ITextFileEditorModelManager
,
TextFileCreateEvent
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IRevertOptions
,
IEncodingSupport
}
from
'
vs/workbench/common/editor
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IFileService
,
FileOperationError
,
FileOperationResult
,
IFileStatWithMetadata
,
ICreateFileOptions
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -16,7 +16,6 @@ import { IUntitledTextEditorService, IUntitledTextEditorModelManager } from 'vs/
import
{
UntitledTextEditorModel
}
from
'
vs/workbench/services/untitled/common/untitledTextEditorModel
'
;
import
{
TextFileEditorModelManager
}
from
'
vs/workbench/services/textfile/common/textFileEditorModelManager
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
createTextBufferFactoryFromSnapshot
,
createTextBufferFactoryFromStream
}
from
'
vs/editor/common/model/textModel
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
...
...
@@ -31,7 +30,6 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import
{
ITextModelService
,
IResolvedTextEditorModel
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
BaseTextEditorModel
}
from
'
vs/workbench/common/editor/textEditorModel
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
suggestFilename
}
from
'
vs/base/common/mime
'
;
import
{
IRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
import
{
isValidBasename
}
from
'
vs/base/common/extpath
'
;
...
...
@@ -217,18 +215,6 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
return
undefined
;
}
private
getFileModels
(
resources
?:
URI
[]):
ITextFileEditorModel
[]
{
if
(
Array
.
isArray
(
resources
))
{
return
coalesce
(
resources
.
map
(
resource
=>
this
.
files
.
get
(
resource
)));
}
return
this
.
files
.
getAll
();
}
private
getDirtyFileModels
(
resources
?:
URI
[]):
ITextFileEditorModel
[]
{
return
this
.
getFileModels
(
resources
).
filter
(
model
=>
model
.
isDirty
());
}
async
saveAs
(
source
:
URI
,
target
?:
URI
,
options
?:
ITextFileSaveOptions
):
Promise
<
URI
|
undefined
>
{
// Get to target resource
...
...
@@ -476,34 +462,12 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
}
// File
return
!
(
await
this
.
doRevertFiles
([
resource
],
options
)).
results
.
some
(
result
=>
result
.
error
);
}
private
async
doRevertFiles
(
resources
:
URI
[],
options
?:
IRevertOptions
):
Promise
<
ITextFileOperationResult
>
{
const
fileModels
=
options
?.
force
?
this
.
getFileModels
(
resources
)
:
this
.
getDirtyFileModels
(
resources
);
const
mapResourceToResult
=
new
ResourceMap
<
IResult
>
();
fileModels
.
forEach
(
fileModel
=>
{
mapResourceToResult
.
set
(
fileModel
.
resource
,
{
source
:
fileModel
.
resource
});
});
await
Promise
.
all
(
fileModels
.
map
(
async
model
=>
{
// Revert through model
await
model
.
revert
(
options
);
// If model is still dirty, mark the resulting operation as error
if
(
model
.
isDirty
())
{
const
result
=
mapResourceToResult
.
get
(
model
.
resource
);
if
(
result
)
{
result
.
error
=
true
;
}
}
}));
const
model
=
this
.
files
.
get
(
resource
);
if
(
model
&&
(
model
.
isDirty
()
||
options
?.
force
))
{
return
model
.
revert
(
options
);
}
return
{
results
:
mapResourceToResult
.
values
()
}
;
return
false
;
}
//#endregion
...
...
src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts
浏览文件 @
abe68eb7
...
...
@@ -50,9 +50,6 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
private
readonly
_onDidChangeEncoding
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onDidChangeEncoding
=
this
.
_onDidChangeEncoding
.
event
;
private
readonly
_onDidChangeOrphaned
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onDidChangeOrphaned
=
this
.
_onDidChangeOrphaned
.
event
;
saveErrorHandler
=
(()
=>
{
const
notificationService
=
this
.
notificationService
;
...
...
@@ -285,7 +282,6 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
listeners
.
add
(
model
.
onDidSave
(
reason
=>
this
.
_onDidSave
.
fire
({
model
:
newModel
,
reason
})));
listeners
.
add
(
model
.
onDidRevert
(()
=>
this
.
_onDidRevert
.
fire
(
newModel
)));
listeners
.
add
(
model
.
onDidChangeEncoding
(()
=>
this
.
_onDidChangeEncoding
.
fire
(
newModel
)));
listeners
.
add
(
model
.
onDidChangeOrphaned
(()
=>
this
.
_onDidChangeOrphaned
.
fire
(
newModel
)));
this
.
mapResourceToModelListeners
.
set
(
resource
,
listeners
);
}
...
...
src/vs/workbench/services/textfile/common/textfiles.ts
浏览文件 @
abe68eb7
...
...
@@ -336,7 +336,8 @@ export interface ITextFileEditorModelManager {
readonly
onDidSave
:
Event
<
ITextFileModelSaveEvent
>
;
readonly
onDidRevert
:
Event
<
ITextFileEditorModel
>
;
readonly
onDidChangeEncoding
:
Event
<
ITextFileEditorModel
>
;
readonly
onDidChangeOrphaned
:
Event
<
ITextFileEditorModel
>
;
saveErrorHandler
:
ISaveErrorHandler
;
get
(
resource
:
URI
):
ITextFileEditorModel
|
undefined
;
getAll
():
ITextFileEditorModel
[];
...
...
@@ -346,8 +347,6 @@ export interface ITextFileEditorModelManager {
addSaveParticipant
(
participant
:
ITextFileSaveParticipant
):
IDisposable
;
runSaveParticipants
(
model
:
IResolvedTextFileEditorModel
,
context
:
{
reason
:
SaveReason
;
},
token
:
CancellationToken
):
Promise
<
void
>
saveErrorHandler
:
ISaveErrorHandler
;
disposeModel
(
model
:
ITextFileEditorModel
):
void
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录