remove timeouts (and their settings) for format and code actions, #87449

This commit is contained in:
Johannes Rieken
2020-01-09 12:53:41 +01:00
parent 082511b4fe
commit f7fb208b39
3 changed files with 5 additions and 50 deletions
@@ -238,25 +238,9 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
return undefined;
}
return new Promise<any>((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<number>('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<number>('editor.codeActionsOnSaveTimeout', settingsOverrides);
progress.report({ message: localize('codeaction', "Quick Fixes") });
return Promise.race([
new Promise<void>((_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<void> {
@@ -40,13 +40,7 @@ const codeActionsOnSaveSchema: IConfigurationPropertySchema = {
export const editorConfiguration = Object.freeze<IConfigurationNode>({
...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
}
});
@@ -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,
}
}
});