Range error with scrollpastend addon

Hello, my app was crashing constantly at startup. I manged to pinpoint the location - it happened at

editor.swapDoc()

with scrollpastend addon enabled and only with documents not bigger than a line or two and never with a single line documents.

When I added try catch block to the updateBottomMargin function, I was getting:

RangeError: Maximum call stack size exceeded message: “Maximum call stack size exceeded”

so smth must be in a loop there.
Edit: cm.on("refresh", updateBottomMargin); is called in loop!

I’m not sure why is that, but I am posting this here; maybe Mr. Marijn will know.

With added try catch block my app does start up, but with a big delay, then everything works as expected.

I am using latest version of CodeMirror and scrollpastend addon.

regards,
iztok

I couldn’t reproduce this, but I think this patch should help.

I tested patched version with the exact same setup that was causing problems before and they are gone. No more infinite loops. Thanks!
Regards,
iztok