extensions/markdown-language-features/preview-src/scroll-sync.ts/getEditorLineNumberForPageOffset
export function getEditorLineNumberForPageOffset(offset: number, documentVersion: number) {
	const { previous, next } = getLineElementsAtPageOffset(offset, documentVersion);
	if (previous) {
		const previousBounds = getElementBounds(previous);
		const offsetFromPrevious = (offset - window.scrollY - previousBounds.top);
		if (next) {
			const progressBetweenElements = offsetFromPrevious / (getElementBounds(next).top - previousBounds.top);
			return previous.line + progressBetweenElements * (next.line - previous.line);
		} else {
			const progressWithinElement = offsetFromPrevious / (previousBounds.height);
			return previous.line + progressWithinElement;
		}
	}
	return null;
}