From 3ebb8c2c5deb19cb697f164f66aead4eb56ef9b1 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 27 Oct 2017 11:10:38 +0200 Subject: [PATCH] compute more minimal edits in format save participants, fixes #30010 --- .../api/electron-browser/mainThreadSaveParticipant.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts index d46aff79813..d81c18b6085 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts @@ -24,6 +24,7 @@ import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textF import { ExtHostContext, ExtHostDocumentSaveParticipantShape, IExtHostContext } from '../node/extHost.protocol'; 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'; export interface INamedSaveParticpant extends ISaveParticipant { readonly name: string; @@ -180,6 +181,7 @@ class FormatOnSaveParticipant implements INamedSaveParticpant { constructor( @ICodeEditorService private _editorService: ICodeEditorService, + @IEditorWorkerService private _editorWorkerService: IEditorWorkerService, @IConfigurationService private _configurationService: IConfigurationService ) { // Nothing @@ -198,7 +200,9 @@ class FormatOnSaveParticipant implements INamedSaveParticpant { return new TPromise((resolve, reject) => { setTimeout(reject, 750); - getDocumentFormattingEdits(model, { tabSize, insertSpaces }).then(resolve, reject); + getDocumentFormattingEdits(model, { tabSize, insertSpaces }) + .then(edits => this._editorWorkerService.computeMoreMinimalEdits(model.uri, edits)) + .then(resolve, reject); }).then(edits => { if (edits && versionNow === model.getVersionId()) { @@ -277,12 +281,13 @@ export class SaveParticipant implements ISaveParticipant { @ITelemetryService private _telemetryService: ITelemetryService, @IInstantiationService instantiationService: IInstantiationService, @IConfigurationService configurationService: IConfigurationService, - @ICodeEditorService codeEditorService: ICodeEditorService + @ICodeEditorService codeEditorService: ICodeEditorService, + @IEditorWorkerService editorWorkerService: IEditorWorkerService ) { this._saveParticipants = [ new TrimWhitespaceParticipant(configurationService, codeEditorService), - new FormatOnSaveParticipant(codeEditorService, configurationService), + new FormatOnSaveParticipant(codeEditorService, editorWorkerService, configurationService), new FinalNewLineParticipant(configurationService, codeEditorService), new TrimFinalNewLinesParticipant(configurationService, codeEditorService), new ExtHostSaveParticipant(extHostContext) -- GitLab