-
Notifications
You must be signed in to change notification settings - Fork 42
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
AlexVanGogen
wants to merge
5
commits into
JetBrains:main
Choose a base branch
from
AlexVanGogen:690-synchronized-scrolling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Markdown: synchronize scrolling between editor and preview #694
AlexVanGogen
wants to merge
5
commits into
JetBrains:main
from
AlexVanGogen:690-synchronized-scrolling
Conversation
This file contains 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
…#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
changed the title
Markdown: synchronize scrolling between editor and preview (#690)
Markdown: synchronize scrolling between editor and preview
Nov 19, 2024
rock3r
added
markdown
This issue impacts the Markdown rendering subsystem
feature
New feature or request
labels
Nov 19, 2024
rock3r
reviewed
Nov 20, 2024
.../core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockRenderer.kt
Outdated
Show resolved
Hide resolved
- Create a subclass that handles all the scrolling sync stuff - Fix highlighting flickering along the way (introduced by changes in this branch)
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
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.
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).