fix #102718, add formatting indicator

This commit is contained in:
Chuang Yu
2020-08-09 15:25:11 +08:00
parent 4807607637
commit d36c19e19f
+16 -3
View File
@@ -25,7 +25,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { onUnexpectedError } from 'vs/base/common/errors';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { Progress } from 'vs/platform/progress/common/progress';
import { Progress, IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
class FormatOnType implements IEditorContribution {
@@ -231,7 +231,13 @@ class FormatDocumentAction extends EditorAction {
async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
if (editor.hasModel()) {
const instaService = accessor.get(IInstantiationService);
await instaService.invokeFunction(formatDocumentWithSelectedProvider, editor, FormattingMode.Explicit, Progress.None, CancellationToken.None);
const progressService = accessor.get(IProgressService);
return progressService.withProgress({
location: ProgressLocation.Window,
title: nls.localize("formatDocument.label.formatting", "Formatting document...")
}, async () => {
return await instaService.invokeFunction(formatDocumentWithSelectedProvider, editor, FormattingMode.Explicit, Progress.None, CancellationToken.None);
});
}
}
}
@@ -267,7 +273,14 @@ class FormatSelectionAction extends EditorAction {
if (range.isEmpty()) {
range = new Range(range.startLineNumber, 1, range.startLineNumber, model.getLineMaxColumn(range.startLineNumber));
}
await instaService.invokeFunction(formatDocumentRangeWithSelectedProvider, editor, range, FormattingMode.Explicit, CancellationToken.None);
const progressService = accessor.get(IProgressService);
return progressService.withProgress({
location: ProgressLocation.Window,
title: nls.localize("formatSelection.label.formatting", "Formatting selection...")
}, async () => {
return await instaService.invokeFunction(formatDocumentRangeWithSelectedProvider, editor, range, FormattingMode.Explicit, CancellationToken.None);
});
}
}