show generic progress message when running save hooks, #40030

This commit is contained in:
Johannes Rieken
2017-12-12 11:19:41 +01:00
parent d989c95558
commit db328de17a

View File

@@ -24,8 +24,14 @@ import { EditOperation } from 'vs/editor/common/core/editOperation';
import { extHostCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IProgressService2, ProgressLocation } from 'vs/platform/progress/common/progress';
import { localize } from 'vs/nls';
class TrimWhitespaceParticipant implements ISaveParticipant {
export interface ISaveParticipantParticipant extends ISaveParticipant {
// progressMessage: string;
}
class TrimWhitespaceParticipant implements ISaveParticipantParticipant {
constructor(
@IConfigurationService private configurationService: IConfigurationService,
@@ -81,7 +87,7 @@ function findEditor(model: IModel, codeEditorService: ICodeEditorService): ICode
return candidate;
}
export class FinalNewLineParticipant implements ISaveParticipant {
export class FinalNewLineParticipant implements ISaveParticipantParticipant {
constructor(
@IConfigurationService private configurationService: IConfigurationService,
@@ -119,7 +125,7 @@ export class FinalNewLineParticipant implements ISaveParticipant {
}
}
export class TrimFinalNewLinesParticipant implements ISaveParticipant {
export class TrimFinalNewLinesParticipant implements ISaveParticipantParticipant {
constructor(
@IConfigurationService private configurationService: IConfigurationService,
@@ -168,7 +174,7 @@ export class TrimFinalNewLinesParticipant implements ISaveParticipant {
}
}
class FormatOnSaveParticipant implements ISaveParticipant {
class FormatOnSaveParticipant implements ISaveParticipantParticipant {
constructor(
@ICodeEditorService private _editorService: ICodeEditorService,
@@ -236,7 +242,7 @@ class FormatOnSaveParticipant implements ISaveParticipant {
}
}
class ExtHostSaveParticipant implements ISaveParticipant {
class ExtHostSaveParticipant implements ISaveParticipantParticipant {
private _proxy: ExtHostDocumentSaveParticipantShape;
@@ -263,24 +269,20 @@ class ExtHostSaveParticipant implements ISaveParticipant {
@extHostCustomer
export class SaveParticipant implements ISaveParticipant {
private _saveParticipants: ISaveParticipant[];
private _saveParticipants: ISaveParticipantParticipant[];
constructor(
extHostContext: IExtHostContext,
@IInstantiationService instantiationService: IInstantiationService,
@IConfigurationService configurationService: IConfigurationService,
@ICodeEditorService codeEditorService: ICodeEditorService,
@IEditorWorkerService editorWorkerService: IEditorWorkerService
@IProgressService2 private _progressService: IProgressService2,
@IInstantiationService instantiationService: IInstantiationService
) {
this._saveParticipants = [
new TrimWhitespaceParticipant(configurationService, codeEditorService),
new FormatOnSaveParticipant(codeEditorService, editorWorkerService, configurationService),
new FinalNewLineParticipant(configurationService, codeEditorService),
new TrimFinalNewLinesParticipant(configurationService, codeEditorService),
new ExtHostSaveParticipant(extHostContext)
instantiationService.createInstance(TrimWhitespaceParticipant),
instantiationService.createInstance(FormatOnSaveParticipant),
instantiationService.createInstance(FinalNewLineParticipant),
instantiationService.createInstance(TrimFinalNewLinesParticipant),
instantiationService.createInstance(ExtHostSaveParticipant, extHostContext),
];
// Hook into model
TextFileEditorModel.setSaveParticipant(this);
}
@@ -290,10 +292,12 @@ export class SaveParticipant implements ISaveParticipant {
}
participate(model: ITextFileEditorModel, env: { reason: SaveReason }): Thenable<void> {
const promiseFactory = this._saveParticipants.map(p => () => {
return Promise.resolve(p.participate(model, env));
return this._progressService.withProgress({ location: ProgressLocation.Window }, progress => {
progress.report({ message: localize('saveParticipants', "Running Save Participants...") });
const promiseFactory = this._saveParticipants.map(p => () => {
return Promise.resolve(p.participate(model, env));
});
return sequence(promiseFactory).then(() => { });
});
return sequence(promiseFactory).then(() => { });
}
}