src/vs/workbench/browser/parts/editor/editorStatus.ts/ChangeModeAction/run
class ChangeModeAction:	override async run(event: unknown, data?: ITelemetryData): Promise<void> {
		const activeTextEditorControl = getCodeEditor(this.editorService.activeTextEditorControl);
		if (!activeTextEditorControl) {
			await this.quickInputService.pick([{ label: localize('noEditor', "No text editor active at this time") }]);
			return;
		}

		const textModel = activeTextEditorControl.getModel();
		const resource = EditorResourceAccessor.getOriginalUri(this.editorService.activeEditor, { supportSideBySide: SideBySideEditor.PRIMARY });

		let hasLanguageSupport = !!resource;
		if (resource?.scheme === Schemas.untitled && !this.textFileService.untitled.get(resource)?.hasAssociatedFilePath) {
			hasLanguageSupport = false; // no configuration for untitled resources (e.g. "Untitled-1")
		}

		// Compute mode
		let currentLanguageId: string | undefined;
		let currentModeId: string | undefined;
		if (textModel) {
			currentModeId = textModel.getLanguageIdentifier().language;
			currentLanguageId = withNullAsUndefined(this.modeService.getLanguageName(currentModeId));
		}

		// All languages are valid picks
		const languages = this.modeService.getRegisteredLanguageNames();
		const picks: QuickPickInput[] = languages.sort().map(lang => {
			const modeId = this.modeService.getModeIdForLanguageName(lang.toLowerCase()) || 'unknown';
			const extensions = this.modeService.getExtensions(lang).join(' ');
			let description: string;
			if (currentLanguageId === lang) {
				description = localize('languageDescription', "({0}) - Configured Language", modeId);
			} else {
				description = localize('languageDescriptionConfigured', "({0})", modeId);
			}

			return {
				label: lang,
				meta: extensions,
				iconClasses: getIconClassesForModeId(modeId),
				description
			};
		});

		if (hasLanguageSupport) {
			picks.unshift({ type: 'separator', label: localize('languagesPicks', "languages (identifier)") });
		}

		// Offer action to configure via settings
		let configureModeAssociations: IQuickPickItem | undefined;
		let configureModeSettings: IQuickPickItem | undefined;
		let galleryAction: Action | undefined;
		if (hasLanguageSupport && resource) {
			const ext = extname(resource) || basename(resource);

			galleryAction = this.instantiationService.createInstance(ShowLanguageExtensionsAction, ext);
			if (galleryAction.enabled) {
				picks.unshift(galleryAction);
			}

			configureModeSettings = { label: localize('configureModeSettings', "Configure '{0}' language based settings...", currentLanguageId) };
			picks.unshift(configureModeSettings);
			configureModeAssociations = { label: localize('configureAssociationsExt', "Configure File Association for '{0}'...", ext) };
			picks.unshift(configureModeAssociations);
		}

		// Offer to "Auto Detect"
		const autoDetectMode: IQuickPickItem = {
			label: localize('autoDetect', "Auto Detect")
		};

		if (hasLanguageSupport) {
			picks.unshift(autoDetectMode);
		}

		const pick = await this.quickInputService.pick(picks, { placeHolder: localize('pickLanguage', "Select Language Mode"), matchOnDescription: true });
		if (!pick) {
			return;
		}

		if (pick === galleryAction) {
			galleryAction.run();
			return;
		}

		// User decided to permanently configure associations, return right after
		if (pick === configureModeAssociations) {
			if (resource) {
				this.configureFileAssociation(resource);
			}
			return;
		}

		// User decided to configure settings for current language
		if (pick === configureModeSettings) {
			this.preferencesService.openGlobalSettings(true, { revealSetting: { key: `[${withUndefinedAsNull(currentModeId)}]`, edit: true } });
			return;
		}

		// Change mode for active editor
		const activeEditor = this.editorService.activeEditor;
		if (activeEditor) {
			const modeSupport = toEditorWithModeSupport(activeEditor);
			if (modeSupport) {

				// Find mode
				let languageSelection: ILanguageSelection | undefined;
				if (pick === autoDetectMode) {
					if (textModel) {
						const resource = EditorResourceAccessor.getOriginalUri(activeEditor, { supportSideBySide: SideBySideEditor.PRIMARY });
						if (resource) {
							languageSelection = this.modeService.createByFilepathOrFirstLine(resource, textModel.getLineContent(1));
						}
					}
				} else {
					languageSelection = this.modeService.createByLanguageName(pick.label);
				}

				// Change mode
				if (typeof languageSelection !== 'undefined') {
					modeSupport.setMode(languageSelection.languageIdentifier.language);
				}
			}

			activeTextEditorControl.focus();
			this.telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', {
				id: ChangeModeAction.ID,
				from: data?.from || 'quick open'
			});
		}
	}