提交 ac944e94 编写于 作者: R Robin

make the timeout for formatOnSave configurable

上级 68054914
......@@ -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<ISingleEditOperation[]>((resolve, reject) => {
setTimeout(reject, 750);
setTimeout(reject, timeout);
getDocumentFormattingEdits(model, { tabSize, insertSpaces })
.then(edits => this._editorWorkerService.computeMoreMinimalEdits(model.uri, edits))
.then(resolve, err => {
......
......@@ -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
}
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册