diff --git a/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts b/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts index ad1cc921d17..64d9ae97df7 100644 --- a/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts +++ b/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts @@ -238,25 +238,9 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant { return undefined; } - return new Promise((resolve, reject) => { - - progress.report({ message: localize('formatting', "Formatting") }); - - const source = new CancellationTokenSource(token); - const editorOrModel = findEditor(model, this._codeEditorService) || model; - const timeout = this._configurationService.getValue('editor.formatOnSaveTimeout', overrides) * 1000; - const request = this._instantiationService.invokeFunction(formatDocumentWithSelectedProvider, editorOrModel, FormattingMode.Silent, source.token); - - setTimeout(() => { - reject(new SaveParticipantError( - localize('timeout.formatOnSave', "Aborted format on save after {0}ms", timeout), - 'editor.formatOnSaveTimeout' - )); - source.cancel(); - }, timeout); - - request.then(resolve, reject); - }); + progress.report({ message: localize('formatting', "Formatting") }); + const editorOrModel = findEditor(model, this._codeEditorService) || model; + await this._instantiationService.invokeFunction(formatDocumentWithSelectedProvider, editorOrModel, FormattingMode.Silent, token); } } @@ -305,25 +289,8 @@ class CodeActionOnSaveParticipant implements ISaveParticipantParticipant { .filter(x => setting[x] === false) .map(x => new CodeActionKind(x)); - const tokenSource = new CancellationTokenSource(token); - - const timeout = this._configurationService.getValue('editor.codeActionsOnSaveTimeout', settingsOverrides); - progress.report({ message: localize('codeaction', "Quick Fixes") }); - - return Promise.race([ - new Promise((_resolve, reject) => - setTimeout(() => { - tokenSource.cancel(); - reject(new SaveParticipantError( - localize('codeActionsOnSave.didTimeout', "Aborted codeActionsOnSave after {0}ms", timeout), - 'editor.codeActionsOnSaveTimeout' - )); - }, timeout)), - this.applyOnSaveActions(model, codeActionsOnSave, excludedActions, tokenSource.token) - ]).finally(() => { - tokenSource.cancel(); - }); + await this.applyOnSaveActions(model, codeActionsOnSave, excludedActions, token); } private async applyOnSaveActions(model: ITextModel, codeActionsOnSave: readonly CodeActionKind[], excludes: readonly CodeActionKind[], token: CancellationToken): Promise { diff --git a/src/vs/workbench/contrib/codeActions/common/codeActionsContribution.ts b/src/vs/workbench/contrib/codeActions/common/codeActionsContribution.ts index 53153e88dca..16c1f7aa131 100644 --- a/src/vs/workbench/contrib/codeActions/common/codeActionsContribution.ts +++ b/src/vs/workbench/contrib/codeActions/common/codeActionsContribution.ts @@ -40,13 +40,7 @@ const codeActionsOnSaveSchema: IConfigurationPropertySchema = { export const editorConfiguration = Object.freeze({ ...editorConfigurationBaseNode, properties: { - 'editor.codeActionsOnSave': codeActionsOnSaveSchema, - 'editor.codeActionsOnSaveTimeout': { - type: 'number', - default: 750, - description: nls.localize('codeActionsOnSaveTimeout', "Timeout in milliseconds after which the code actions that are run on save are cancelled."), - scope: ConfigurationScope.RESOURCE_LANGUAGE, - }, + 'editor.codeActionsOnSave': codeActionsOnSaveSchema } }); diff --git a/src/vs/workbench/contrib/files/browser/files.contribution.ts b/src/vs/workbench/contrib/files/browser/files.contribution.ts index e78e63d4c3e..39744d2ae4a 100644 --- a/src/vs/workbench/contrib/files/browser/files.contribution.ts +++ b/src/vs/workbench/contrib/files/browser/files.contribution.ts @@ -344,12 +344,6 @@ configurationRegistry.registerConfiguration({ 'default': false, 'description': nls.localize('formatOnSave', "Format a file on save. A formatter must be available, the file must not be saved after delay, and the editor must not be shutting down."), scope: ConfigurationScope.RESOURCE_LANGUAGE, - }, - 'editor.formatOnSaveTimeout': { - 'type': 'number', - 'default': 750, - 'description': nls.localize('formatOnSaveTimeout', "Timeout in milliseconds after which the formatting that is run on file save is cancelled."), - scope: ConfigurationScope.RESOURCE_LANGUAGE, } } });