[Work in progress] Keep current position when zooming the document

This PR is an attempt to rewrite #3446 from the ground up, to hopefully be able to pinpoint and fix the bugs in that implementation.

/cc @brendandahl