Cannot initially scroll all the way down in a large document

I’m encountering an issue with scrolling where I have a large CM6 document. The language is Markdown with custom extensions.

This video shows the issue:

In short, the first time the user scrolls through the document, the user cannot scroll to the end by moving the cursor to the bottom of the scroll bar. The user can do this on subsequent scrolls.

So I suspect the issue is that CM is doing some incremental parsing or something, which is changing the size of the editor as the user scrolls. I don’t know if this is therefore easily fixable, but it is still a bug worth reporting. Unless there is a workaround I don’t know? Or if it’s due to the way I set up highlighting for my Markdown extensions?

The editor initially sizes its content element to an estimate of the document height (since much of the content hasn’t been rendered yet). This patch adds some logic to notice when the estimated position of some reference line in the viewport has changed, and moves the scroll position to match.