Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f1c6f2c2
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,体验更适合开发者的 AI 搜索 >>
提交
f1c6f2c2
编写于
2月 17, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
text files - move save error handler into files model manager
上级
2d125bc3
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
20 addition
and
30 deletion
+20
-30
src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.ts
...contrib/files/browser/editors/textFileSaveErrorHandler.ts
+1
-1
src/vs/workbench/services/textfile/browser/textFileService.ts
...vs/workbench/services/textfile/browser/textFileService.ts
+0
-13
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
...workbench/services/textfile/common/textFileEditorModel.ts
+1
-1
src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts
...ch/services/textfile/common/textFileEditorModelManager.ts
+15
-1
src/vs/workbench/services/textfile/common/textfiles.ts
src/vs/workbench/services/textfile/common/textfiles.ts
+2
-6
src/vs/workbench/services/textfile/electron-browser/nativeTextFileService.ts
...rvices/textfile/electron-browser/nativeTextFileService.ts
+1
-3
src/vs/workbench/test/browser/workbenchTestServices.ts
src/vs/workbench/test/browser/workbenchTestServices.ts
+0
-2
src/vs/workbench/test/electron-browser/workbenchTestServices.ts
.../workbench/test/electron-browser/workbenchTestServices.ts
+0
-3
未找到文件。
src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.ts
浏览文件 @
f1c6f2c2
...
...
@@ -64,7 +64,7 @@ export class TextFileSaveErrorHandler extends Disposable implements ISaveErrorHa
this
.
_register
(
textModelService
.
registerTextModelContentProvider
(
CONFLICT_RESOLUTION_SCHEME
,
provider
));
// Set as save error handler to service for text files
this
.
textFileService
.
saveErrorHandler
=
this
;
this
.
textFileService
.
files
.
saveErrorHandler
=
this
;
this
.
registerListeners
();
}
...
...
src/vs/workbench/services/textfile/browser/textFileService.ts
浏览文件 @
f1c6f2c2
...
...
@@ -33,8 +33,6 @@ 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
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
{
IRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
import
{
isValidBasename
}
from
'
vs/base/common/extpath
'
;
...
...
@@ -59,16 +57,6 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
readonly
untitled
:
IUntitledTextEditorModelManager
=
this
.
untitledTextEditorService
;
saveErrorHandler
=
(()
=>
{
const
notificationService
=
this
.
notificationService
;
return
{
onSaveError
(
error
:
Error
,
model
:
ITextFileEditorModel
):
void
{
notificationService
.
error
(
nls
.
localize
(
'
genericSaveError
'
,
"
Failed to save '{0}': {1}
"
,
model
.
name
,
toErrorMessage
(
error
,
false
)));
}
};
})();
abstract
get
encoding
():
IResourceEncodings
;
constructor
(
...
...
@@ -84,7 +72,6 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
@
IFilesConfigurationService
protected
readonly
filesConfigurationService
:
IFilesConfigurationService
,
@
ITextModelService
private
readonly
textModelService
:
ITextModelService
,
@
ICodeEditorService
private
readonly
codeEditorService
:
ICodeEditorService
,
@
INotificationService
private
readonly
notificationService
:
INotificationService
,
@
IRemotePathService
private
readonly
remotePathService
:
IRemotePathService
)
{
super
();
...
...
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
浏览文件 @
f1c6f2c2
...
...
@@ -738,7 +738,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
}
// Show to user
this
.
textFileService
.
saveErrorHandler
.
onSaveError
(
error
,
this
);
this
.
textFileService
.
files
.
saveErrorHandler
.
onSaveError
(
error
,
this
);
// Emit as event
this
.
_onDidSaveError
.
fire
();
...
...
src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts
浏览文件 @
f1c6f2c2
...
...
@@ -3,6 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
localize
}
from
'
vs/nls
'
;
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
TextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textFileEditorModel
'
;
...
...
@@ -18,6 +20,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import
{
TextFileSaveParticipant
}
from
'
vs/workbench/services/textfile/common/textFileSaveParticipant
'
;
import
{
SaveReason
}
from
'
vs/workbench/common/editor
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
export
class
TextFileEditorModelManager
extends
Disposable
implements
ITextFileEditorModelManager
{
...
...
@@ -42,6 +45,16 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
private
readonly
_onDidChangeOrphaned
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onDidChangeOrphaned
=
this
.
_onDidChangeOrphaned
.
event
;
saveErrorHandler
=
(()
=>
{
const
notificationService
=
this
.
notificationService
;
return
{
onSaveError
(
error
:
Error
,
model
:
ITextFileEditorModel
):
void
{
notificationService
.
error
(
localize
(
'
genericSaveError
'
,
"
Failed to save '{0}': {1}
"
,
model
.
name
,
toErrorMessage
(
error
,
false
)));
}
};
})();
private
readonly
mapResourceToModel
=
new
ResourceMap
<
ITextFileEditorModel
>
();
private
readonly
mapResourceToModelListeners
=
new
ResourceMap
<
IDisposable
>
();
private
readonly
mapResourceToDisposeListener
=
new
ResourceMap
<
IDisposable
>
();
...
...
@@ -52,7 +65,8 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
constructor
(
@
ILifecycleService
private
readonly
lifecycleService
:
ILifecycleService
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IFileService
private
readonly
fileService
:
IFileService
@
IFileService
private
readonly
fileService
:
IFileService
,
@
INotificationService
private
readonly
notificationService
:
INotificationService
)
{
super
();
...
...
src/vs/workbench/services/textfile/common/textfiles.ts
浏览文件 @
f1c6f2c2
...
...
@@ -52,12 +52,6 @@ export interface ITextFileService extends IDisposable {
*/
readonly
encoding
:
IResourceEncodings
;
/**
* The handler that should be called when saving fails. Can be overridden
* to handle save errors in a custom way.
*/
saveErrorHandler
:
ISaveErrorHandler
;
/**
* A resource is dirty if it has unsaved changes or is an untitled file not yet saved.
*
...
...
@@ -377,6 +371,8 @@ export interface ITextFileEditorModelManager {
addSaveParticipant
(
participant
:
ITextFileSaveParticipant
):
IDisposable
;
runSaveParticipants
(
model
:
IResolvedTextFileEditorModel
,
context
:
{
reason
:
SaveReason
;
},
token
:
CancellationToken
):
Promise
<
void
>
saveErrorHandler
:
ISaveErrorHandler
;
disposeModel
(
model
:
ITextFileEditorModel
):
void
;
}
...
...
src/vs/workbench/services/textfile/electron-browser/nativeTextFileService.ts
浏览文件 @
f1c6f2c2
...
...
@@ -37,7 +37,6 @@ import { assign } from 'vs/base/common/objects';
import
{
IFilesConfigurationService
}
from
'
vs/workbench/services/filesConfiguration/common/filesConfigurationService
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
export
class
NativeTextFileService
extends
AbstractTextFileService
{
...
...
@@ -56,10 +55,9 @@ export class NativeTextFileService extends AbstractTextFileService {
@
IFilesConfigurationService
filesConfigurationService
:
IFilesConfigurationService
,
@
ITextModelService
textModelService
:
ITextModelService
,
@
ICodeEditorService
codeEditorService
:
ICodeEditorService
,
@
INotificationService
notificationService
:
INotificationService
,
@
IRemotePathService
remotePathService
:
IRemotePathService
)
{
super
(
fileService
,
untitledTextEditorService
,
lifecycleService
,
instantiationService
,
modelService
,
environmentService
,
dialogService
,
fileDialogService
,
textResourceConfigurationService
,
filesConfigurationService
,
textModelService
,
codeEditorService
,
notificationService
,
remotePathService
);
super
(
fileService
,
untitledTextEditorService
,
lifecycleService
,
instantiationService
,
modelService
,
environmentService
,
dialogService
,
fileDialogService
,
textResourceConfigurationService
,
filesConfigurationService
,
textModelService
,
codeEditorService
,
remotePathService
);
}
private
_encoding
:
EncodingOracle
|
undefined
;
...
...
src/vs/workbench/test/browser/workbenchTestServices.ts
浏览文件 @
f1c6f2c2
...
...
@@ -121,7 +121,6 @@ export class TestTextFileService extends BrowserTextFileService {
@
IFilesConfigurationService
filesConfigurationService
:
IFilesConfigurationService
,
@
ITextModelService
textModelService
:
ITextModelService
,
@
ICodeEditorService
codeEditorService
:
ICodeEditorService
,
@
INotificationService
notificationService
:
INotificationService
,
@
IRemotePathService
remotePathService
:
IRemotePathService
)
{
super
(
...
...
@@ -137,7 +136,6 @@ export class TestTextFileService extends BrowserTextFileService {
filesConfigurationService
,
textModelService
,
codeEditorService
,
notificationService
,
remotePathService
);
}
...
...
src/vs/workbench/test/electron-browser/workbenchTestServices.ts
浏览文件 @
f1c6f2c2
...
...
@@ -22,7 +22,6 @@ import { IProductService } from 'vs/platform/product/common/productService';
import
{
IFilesConfigurationService
}
from
'
vs/workbench/services/filesConfiguration/common/filesConfigurationService
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IReadTextFileOptions
,
ITextFileStreamContent
,
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
createTextBufferFactoryFromStream
}
from
'
vs/editor/common/model/textModel
'
;
...
...
@@ -62,7 +61,6 @@ export class TestTextFileService extends NativeTextFileService {
@
IFilesConfigurationService
filesConfigurationService
:
IFilesConfigurationService
,
@
ITextModelService
textModelService
:
ITextModelService
,
@
ICodeEditorService
codeEditorService
:
ICodeEditorService
,
@
INotificationService
notificationService
:
INotificationService
,
@
IRemotePathService
remotePathService
:
IRemotePathService
)
{
super
(
...
...
@@ -79,7 +77,6 @@ export class TestTextFileService extends NativeTextFileService {
filesConfigurationService
,
textModelService
,
codeEditorService
,
notificationService
,
remotePathService
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录