src/vs/workbench/contrib/format/browser/formatActionsMultiple.ts/DefaultFormatter/_selectFormatter
class DefaultFormatter:	private async _selectFormatter<T extends FormattingEditProvider>(formatter: T[], document: ITextModel, mode: FormattingMode): Promise<T | undefined> {

		const defaultFormatterId = this._configService.getValue<string>(DefaultFormatter.configName, {
			resource: document.uri,
			overrideIdentifier: document.getLanguageId()
		});

		if (defaultFormatterId) {
			// good -> formatter configured
			const defaultFormatter = formatter.find(formatter => ExtensionIdentifier.equals(formatter.extensionId, defaultFormatterId));
			if (defaultFormatter) {
				// formatter available
				return defaultFormatter;
			}

			// bad -> formatter gone
			const extension = await this._extensionService.getExtension(defaultFormatterId);
			if (extension && this._extensionEnablementService.isEnabled(toExtension(extension))) {
				// formatter does not target this file
				const langName = this._languageService.getLanguageName(document.getLanguageId()) || document.getLanguageId();
				const detail = nls.localize('miss', "Extension '{0}' is configured as formatter but it cannot format '{1}'-files", extension.displayName || extension.name, langName);
				if (mode === FormattingMode.Silent) {
					this._notificationService.status(detail, { hideAfter: 4000 });
					return undefined;
				} else {
					const result = await this._dialogService.confirm({
						message: nls.localize('miss.1', "Change Default Formatter"),
						detail,
						primaryButton: nls.localize('do.config', "Configure..."),
						secondaryButton: nls.localize('cancel', "Cancel")
					});
					if (result.confirmed) {
						return this._pickAndPersistDefaultFormatter(formatter, document);
					} else {
						return undefined;
					}
				}
			}
		} else if (formatter.length === 1) {
			// ok -> nothing configured but only one formatter available
			return formatter[0];
		}

		const langName = this._languageService.getLanguageName(document.getLanguageId()) || document.getLanguageId();
		const message = !defaultFormatterId
			? nls.localize('config.needed', "There are multiple formatters for '{0}' files. Select a default formatter to continue.", DefaultFormatter._maybeQuotes(langName))
			: nls.localize('config.bad', "Extension '{0}' is configured as formatter but not available. Select a different default formatter to continue.", defaultFormatterId);

		if (mode !== FormattingMode.Silent) {
			// running from a user action -> show modal dialog so that users configure
			// a default formatter
			const result = await this._dialogService.confirm({
				message,
				primaryButton: nls.localize('do.config', "Configure..."),
				secondaryButton: nls.localize('cancel', "Cancel")
			});
			if (result.confirmed) {
				return this._pickAndPersistDefaultFormatter(formatter, document);
			}

		} else {
			// no user action -> show a silent notification and proceed
			this._notificationService.prompt(
				Severity.Info,
				message,
				[{ label: nls.localize('do.config', "Configure..."), run: () => this._pickAndPersistDefaultFormatter(formatter, document) }],
				{ silent: true }
			);
		}
		return undefined;
	}