Skip to main content

Editing / Preview Synchronized Scrolling

Completed

Comments

1 comment

  • Fletcher Penney

    You discuss two separate things.  Accuracy in one is (generally) not related to accuracy in the other.  (Generally, because some of the math is shared, and if I have an error in a calculation it could affect both.  But the overall logic of the two is completely different.)

     

    1. Synchronizing while typing.  This is actually relatively easy -- we know where you type, and I can use that to calculate (roughly) where the resulting text ends up in the preview.  (I say roughly because doing it at the character level would require adding extra bloat to MultiMarkdown, but doing it at the word/phrase level is fast.)  That said, I've been trying to smooth out a few things in the second synchronizing variant, and I can confirm some offset in at least some documents.  I'll look at this, and this should be fixable.

     

    2. Synchronizing while scrolling.  This is harder.  I have discussed this one at length elsewhere, but the short version is that you cannot assume a linear relationship between the editor scroll position and the preview scroll position.  For example, imagine a few screens of text, followed by a series of large graphic figures, followed by a few screens of text.  The images could be quite tall in the preview, but only a single line high in the editor.  Over the years I have worked on some algorithms that match the editor with the preview.  There will always be edge cases, but for "normal" documents it does a reasonably good job.  One key exception is that if you include lots of raw HTML in your document, you will probably break synchronization.  The default fallback, however, is to assume a linear relationship so you're not any worse off than you would be in other editors.  With the obvious exception that if there is a bug in the calculations that will throw things off.

     

    I'll dig back and see if there is a recently introduced error in the calculations that is throwing the results off.

    0

Please sign in to leave a comment.

Powered by Zendesk