src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.ts/LanguageDetectionSimpleWorker/detectLanguage
class LanguageDetectionSimpleWorker:	public async detectLanguage(uri: string, langBiases: Record<string, number> | undefined, preferHistory: boolean): Promise<string | undefined> {
		const languages: string[] = [];
		const confidences: number[] = [];
		const stopWatch = new StopWatch(true);
		const documentTextSample = this.getTextForDetection(uri);
		if (!documentTextSample) { return; }

		const neuralResolver = async () => {
			for await (const language of this.detectLanguagesImpl(documentTextSample)) {
				languages.push(language.languageId);
				confidences.push(language.confidence);
			}
			stopWatch.stop();

			if (languages.length) {
				this._host.fhr('sendTelemetryEvent', [languages, confidences, stopWatch.elapsed()]);
				return languages[0];
			}
			return undefined;
		};

		const historicalResolver = async () => {
			if (langBiases) {
				const regexpDetection = await this.runRegexpModel(documentTextSample, langBiases);
				if (regexpDetection) {
					return regexpDetection;
				}
			}
			return undefined;
		};

		if (preferHistory) {
			const history = await historicalResolver();
			if (history) { return history; }
			const neural = await neuralResolver();
			if (neural) { return neural; }
		} else {
			const neural = await neuralResolver();
			if (neural) { return neural; }
			const history = await historicalResolver();
			if (history) { return history; }
		}

		return undefined;
	}