提交 5cdd59f9 编写于 作者: J Johannes Rieken

be relaxed when having one formatter and no config

上级 63cca55c
......@@ -105,11 +105,12 @@ export abstract class FormattingConflicts {
}
static async select<T extends (DocumentFormattingEditProvider | DocumentRangeFormattingEditProvider)>(formatter: T[], document: ITextModel, mode: FormattingMode): Promise<T | undefined> {
if (formatter.length > 1) {
const { value: selector } = FormattingConflicts._selectors.iterator().next();
if (selector) {
return await selector(formatter, document, mode);
}
if (formatter.length === 0) {
return undefined;
}
const { value: selector } = FormattingConflicts._selectors.iterator().next();
if (selector) {
return await selector(formatter, document, mode);
}
return formatter[0];
}
......
......@@ -78,6 +78,9 @@ class DefaultFormatter extends Disposable implements IWorkbenchContribution {
// good -> formatter configured and available
return defaultFormatter;
}
} else if (formatter.length === 1) {
// ok -> nothing configured but only one formatter available
return formatter[0];
}
const langName = this._modeService.getLanguageName(document.getModeId()) || document.getModeId();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册