debt - move save error handler and participant into service

This commit is contained in:
Benjamin Pasero
2020-01-27 13:00:01 +01:00
parent 50782c1d5a
commit bf1e90a37e
9 changed files with 55 additions and 51 deletions

View File

@@ -28,8 +28,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ILogService } from 'vs/platform/log/common/log';
import { IProgressService, ProgressLocation, IProgressStep, IProgress } from 'vs/platform/progress/common/progress';
import { extHostCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { ISaveParticipant, IResolvedTextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
import { ISaveParticipant, IResolvedTextFileEditorModel, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { SaveReason } from 'vs/workbench/common/editor';
import { ExtHostContext, ExtHostDocumentSaveParticipantShape, IExtHostContext } from '../common/extHost.protocol';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -356,6 +355,7 @@ export class SaveParticipant implements ISaveParticipant {
@IProgressService private readonly _progressService: IProgressService,
@ILogService private readonly _logService: ILogService,
@ILabelService private readonly _labelService: ILabelService,
@ITextFileService private readonly _textFileService: ITextFileService
) {
this._saveParticipants = new IdleValue(() => [
instantiationService.createInstance(TrimWhitespaceParticipant),
@@ -365,12 +365,12 @@ export class SaveParticipant implements ISaveParticipant {
instantiationService.createInstance(TrimFinalNewLinesParticipant),
instantiationService.createInstance(ExtHostSaveParticipant, extHostContext),
]);
// Hook into model
TextFileEditorModel.setSaveParticipant(this);
// Set as save participant for all text files
this._textFileService.saveParticipant = this;
}
dispose(): void {
TextFileEditorModel.setSaveParticipant(null);
this._textFileService.saveParticipant = undefined;
this._saveParticipants.dispose();
}