Skip to content

Commit 5cdd59f

Browse files
committed
be relaxed when having one formatter and no config
1 parent 63cca55 commit 5cdd59f

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,12 @@ export abstract class FormattingConflicts {
105105
}
106106

107107
static async select<T extends (DocumentFormattingEditProvider | DocumentRangeFormattingEditProvider)>(formatter: T[], document: ITextModel, mode: FormattingMode): Promise<T | undefined> {
108-
if (formatter.length > 1) {
109-
const { value: selector } = FormattingConflicts._selectors.iterator().next();
110-
if (selector) {
111-
return await selector(formatter, document, mode);
112-
}
108+
if (formatter.length === 0) {
109+
return undefined;
110+
}
111+
const { value: selector } = FormattingConflicts._selectors.iterator().next();
112+
if (selector) {
113+
return await selector(formatter, document, mode);
113114
}
114115
return formatter[0];
115116
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ class DefaultFormatter extends Disposable implements IWorkbenchContribution {
7878
// good -> formatter configured and available
7979
return defaultFormatter;
8080
}
81+
} else if (formatter.length === 1) {
82+
// ok -> nothing configured but only one formatter available
83+
return formatter[0];
8184
}
8285

8386
const langName = this._modeService.getLanguageName(document.getModeId()) || document.getModeId();

0 commit comments

Comments
 (0)