src/vs/workbench/common/editor/textResourceEditorInput.ts/TextResourceEditorInput/resolve
class TextResourceEditorInput:	override async resolve(): Promise<ITextEditorModel> {

		// Unset preferred contents and mode after resolving
		// once to prevent these properties to stick. We still
		// want the user to change the language mode in the editor
		// and want to show updated contents (if any) in future
		// `resolve` calls.
		const preferredContents = this.preferredContents;
		const preferredMode = this.preferredMode;
		this.preferredContents = undefined;
		this.preferredMode = undefined;

		if (!this.modelReference) {
			this.modelReference = this.textModelResolverService.createModelReference(this.resource);
		}

		const ref = await this.modelReference;

		// Ensure the resolved model is of expected type
		const model = ref.object;
		if (!(model instanceof TextResourceEditorModel)) {
			ref.dispose();
			this.modelReference = undefined;

			throw new Error(`Unexpected model for TextResourceEditorInput: ${this.resource}`);
		}

		this.cachedModel = model;

		// Set contents and mode if preferred
		if (typeof preferredContents === 'string' || typeof preferredMode === 'string') {
			model.updateTextEditorModel(typeof preferredContents === 'string' ? createTextBufferFactory(preferredContents) : undefined, preferredMode);
		}

		return model;
	}