Skip to content

Commit ae1953b

Browse files
committed
more cases
1 parent 8f24368 commit ae1953b

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

src/vs/editor/contrib/format/browser/format.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export async function formatDocumentRangesWithSelectedProvider(
105105
rangeOrRanges: Range | Range[],
106106
mode: FormattingMode,
107107
progress: IProgress<DocumentRangeFormattingEditProvider>,
108-
token: CancellationToken
108+
token: CancellationToken,
109+
userGesture: boolean
109110
): Promise<void> {
110111

111112
const instaService = accessor.get(IInstantiationService);
@@ -115,7 +116,7 @@ export async function formatDocumentRangesWithSelectedProvider(
115116
const selected = await FormattingConflicts.select(provider, model, mode);
116117
if (selected) {
117118
progress.report(selected);
118-
await instaService.invokeFunction(formatDocumentRangesWithProvider, selected, editorOrModel, rangeOrRanges, token);
119+
await instaService.invokeFunction(formatDocumentRangesWithProvider, selected, editorOrModel, rangeOrRanges, token, userGesture);
119120
}
120121
}
121122

@@ -124,7 +125,8 @@ export async function formatDocumentRangesWithProvider(
124125
provider: DocumentRangeFormattingEditProvider,
125126
editorOrModel: ITextModel | IActiveCodeEditor,
126127
rangeOrRanges: Range | Range[],
127-
token: CancellationToken
128+
token: CancellationToken,
129+
userGesture: boolean
128130
): Promise<boolean> {
129131
const workerService = accessor.get(IEditorWorkerService);
130132
const logService = accessor.get(ILogService);
@@ -272,7 +274,7 @@ export async function formatDocumentRangesWithProvider(
272274
return null;
273275
});
274276
}
275-
accessibleNotificationService.notify(AccessibleNotificationEvent.Format);
277+
accessibleNotificationService.notify(AccessibleNotificationEvent.Format, userGesture);
276278
return true;
277279
}
278280

src/vs/editor/contrib/format/browser/formatActions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class FormatOnType implements IEditorContribution {
143143
return;
144144
}
145145
if (isNonEmptyArray(edits)) {
146-
this._accessibleNotificationService.notify(AccessibleNotificationEvent.Format);
146+
this._accessibleNotificationService.notify(AccessibleNotificationEvent.Format, false);
147147
FormattingEdit.execute(this._editor, edits, true);
148148
}
149149
}).finally(() => {
@@ -205,7 +205,7 @@ class FormatOnPaste implements IEditorContribution {
205205
if (this.editor.getSelections().length > 1) {
206206
return;
207207
}
208-
this._instantiationService.invokeFunction(formatDocumentRangesWithSelectedProvider, this.editor, range, FormattingMode.Silent, Progress.None, CancellationToken.None).catch(onUnexpectedError);
208+
this._instantiationService.invokeFunction(formatDocumentRangesWithSelectedProvider, this.editor, range, FormattingMode.Silent, Progress.None, CancellationToken.None, false).catch(onUnexpectedError);
209209
}
210210
}
211211

@@ -278,7 +278,7 @@ class FormatSelectionAction extends EditorAction {
278278

279279
const progressService = accessor.get(IEditorProgressService);
280280
await progressService.showWhile(
281-
instaService.invokeFunction(formatDocumentRangesWithSelectedProvider, editor, ranges, FormattingMode.Explicit, Progress.None, CancellationToken.None),
281+
instaService.invokeFunction(formatDocumentRangesWithSelectedProvider, editor, ranges, FormattingMode.Explicit, Progress.None, CancellationToken.None, true),
282282
250
283283
);
284284
}

src/vs/workbench/contrib/codeEditor/browser/saveParticipants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class FormatOnSaveParticipant implements ITextFileSaveParticipant {
258258

259259
} else if (ranges) {
260260
// formatted modified ranges
261-
await this.instantiationService.invokeFunction(formatDocumentRangesWithSelectedProvider, editorOrModel, ranges, FormattingMode.Silent, nestedProgress, token);
261+
await this.instantiationService.invokeFunction(formatDocumentRangesWithSelectedProvider, editorOrModel, ranges, FormattingMode.Silent, nestedProgress, token, false);
262262
}
263263
}
264264
}

src/vs/workbench/contrib/format/browser/formatActionsMultiple.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ registerEditorAction(class FormatSelectionMultipleAction extends EditorAction {
405405
const provider = languageFeaturesService.documentRangeFormattingEditProvider.ordered(model);
406406
const pick = await instaService.invokeFunction(showFormatterPick, model, provider);
407407
if (typeof pick === 'number') {
408-
await instaService.invokeFunction(formatDocumentRangesWithProvider, provider[pick], editor, range, CancellationToken.None);
408+
await instaService.invokeFunction(formatDocumentRangesWithProvider, provider[pick], editor, range, CancellationToken.None, true);
409409
}
410410

411411
logFormatterTelemetry(telemetryService, 'range', provider, typeof pick === 'number' && provider[pick] || undefined);

src/vs/workbench/contrib/format/browser/formatModified.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ registerEditorAction(class FormatModifiedAction extends EditorAction {
4242
if (isNonEmptyArray(ranges)) {
4343
return instaService.invokeFunction(
4444
formatDocumentRangesWithSelectedProvider, editor, ranges,
45-
FormattingMode.Explicit, Progress.None, CancellationToken.None
45+
FormattingMode.Explicit, Progress.None, CancellationToken.None,
46+
true
4647
);
4748
}
4849
}

0 commit comments

Comments
 (0)