Skip to content

Conversation

@jadeglaze
Copy link

@jadeglaze jadeglaze commented Mar 21, 2025

NOTE: DO NOT MERGE. This PR contains more than I intended. It should have been made on top of my other work. I'll fix it, but for now I just wanted to post this temporarily and I'll revisit it after other PRs. (I believe it should only have scrolling.ts and Editor.tsx changes.)

This fixes a nasty jumpiness in scroll syncing when editing. More specifically:

Scroll sync has to interpolate positions of latex display blocks (and other extension blocks) in the preview pane since they're not top level blocks that get tagged with data-source-line. This makes it especially bad when ...

You have some piece of latex code in the middle of the editor, and then you remove the end ']' of the latex block.
This causes a chain of events, roughly: rerendering the preview pane, that latex block is now incomplete so no longer identified as a latex block, scroll sync map rebuilt, scroll sync happens, the editor gets scrolled to a new position that's far from where it was before (maybe even off screen).

The effect of this is that you delete one character and suddenly the editor scrolls to a totally new place.
(To be clear, this can happen when editing non-latex as well, but it's especially bad when editing latex.)

I'm pretty sure it's never desirable for the editor to scroll as a result of editing, so...

This PR introduces a "scroll lock" while editing. It seems to do a great job of stabilizing the editor while editing, but also allows the scroll sync to continue working when you do want it.

@mb21 mb21 marked this pull request as draft March 22, 2025 08:25
@mb21
Copy link
Owner

mb21 commented Mar 22, 2025

Thanks! Probably not related but just FYI: #95

btw. you can probably interactive rebase this branch to change it to contain only those changes. Feel free to git push --force-with-lease this branch then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants