src/vs/workbench/browser/parts/editor/editorStatus.ts/toEditorWithModeSupport
function toEditorWithModeSupport(input: IEditorInput): IModeSupport | null {

	// Untitled Text Editor
	if (input instanceof UntitledTextEditorInput) {
		return input;
	}

	// Side by Side (diff) Editor
	if (input instanceof SideBySideEditorInput) {
		const primaryModeSupport = toEditorWithModeSupport(input.primary);
		const secondaryModeSupport = toEditorWithModeSupport(input.secondary);

		if (primaryModeSupport && secondaryModeSupport) {
			return new SideBySideEditorModeSupport(primaryModeSupport, secondaryModeSupport);
		}

		return primaryModeSupport;
	}

	// File or Resource Editor
	const modeSupport = input as IFileEditorInput;
	if (typeof modeSupport.setMode === 'function') {
		return modeSupport;
	}

	// Unsupported for any other editor
	return null;
}