Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown: synchronize scrolling between editor and preview #694

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

AlexVanGogen
Copy link
Contributor

Small demo of how it works in IntelliJ (source scrolling events are passed to the syncronizer with a debounce timeout of 16ms):

Screen.Recording.2024-11-19.at.12.42.12.mov

I'm also contemplating writing some sanity tests that validate the coherency of internal structures (which means internals of ScrollingSynchronizer will likely be exposed for testing).

…#690)

Only ScrollState is supported because of
its natural ability to scroll the view
to an arbitrary coordinate,

LazyListState doesn't allow this, and it
only gives an opportunity to scroll to
an item in a LazyColumn list and then
to a position within the item.
So, it requires a different approach
(which can hopefully be adjusted to the
proposed ScrollingSynchronizer API).

Note that the change only enables auto-scrolling
in a preview to match the position in the source,
it doesn't work the other way around.
Otherwise, line offsets will be calculated
starting from the outer border of the padding,
and not the border of the padded text,
so they will just be incorrect.
@AlexVanGogen AlexVanGogen changed the title Markdown: synchronize scrolling between editor and preview (#690) Markdown: synchronize scrolling between editor and preview Nov 19, 2024
@rock3r rock3r self-requested a review November 19, 2024 16:13
@rock3r rock3r added markdown This issue impacts the Markdown rendering subsystem feature New feature or request labels Nov 19, 2024
- Create a subclass that handles all the scrolling sync stuff

- Fix highlighting flickering along the way
(introduced by changes in this branch)
@AlexVanGogen
Copy link
Contributor Author

Added some tests. They mostly verify that scrolling position of the preview changes in the right direction when the viewport sources is scrolled. So they don't exactly check that everything's completely in order, but at least they should gatekeep major regressions caused by layounting changes in compose.

Fixes tests that fail because of the missing native library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request markdown This issue impacts the Markdown rendering subsystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants