diff --git a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts index 83ec60aedcf..59d1dec074c 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts @@ -197,8 +197,10 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant { const versionNow = model.getVersionId(); const { tabSize, insertSpaces } = model.getOptions(); + const timeout = this._configurationService.getValue('editor.formatOnSaveTimeout', { overrideIdentifier: model.getLanguageIdentifier().language, resource: editorModel.getResource() }); + return new Promise((resolve, reject) => { - setTimeout(reject, 750); + setTimeout(reject, timeout); getDocumentFormattingEdits(model, { tabSize, insertSpaces }) .then(edits => this._editorWorkerService.computeMoreMinimalEdits(model.uri, edits)) .then(resolve, err => { diff --git a/src/vs/workbench/parts/files/electron-browser/files.contribution.ts b/src/vs/workbench/parts/files/electron-browser/files.contribution.ts index bdc2ca614b6..3cddef4b8ca 100644 --- a/src/vs/workbench/parts/files/electron-browser/files.contribution.ts +++ b/src/vs/workbench/parts/files/electron-browser/files.contribution.ts @@ -298,6 +298,12 @@ configurationRegistry.registerConfiguration({ 'description': nls.localize('formatOnSave', "Format a file on save. A formatter must be available, the file must not be auto-saved, and editor must not be shutting down."), 'overridable': true, 'scope': ConfigurationScope.RESOURCE + }, + 'editor.formatOnSaveTimeout': { + 'type': 'number', + 'default': 750, + 'description': nls.localize('formatOnSaveTimeout', "Format on save timeout. Specifies a time limit in milliseconds for formatOnSave-commands. Commands taking longer than the specified timeout will be cancelled."), + 'scope': ConfigurationScope.RESOURCE } } });