WIP: Fix jumppiness in scroll sync when editing, especially latex#192
Draft
jadeglaze wants to merge 2 commits intomb21:masterfrom
Draft
WIP: Fix jumppiness in scroll sync when editing, especially latex#192jadeglaze wants to merge 2 commits intomb21:masterfrom
jadeglaze wants to merge 2 commits intomb21:masterfrom
Conversation
Owner
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.