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

Fix allow scroll below document #254

Merged
merged 4 commits into from
Sep 19, 2022
Merged

Conversation

danipen
Copy link
Collaborator

@danipen danipen commented Sep 19, 2022

This PR fixes the AllowScrollBelowDocument option. The event chain in the ScrollViewer prevented AvaloniaEdit to reserve more space for the viewport, because when the scrollbar reached the max viewport no new events sent, so the code did not work as WPF.

After these fixes, when the option AllowScrollBelowDocument is enabled, the TextView adds an extra height of Bounds.Height - DefaultLineHeight so the user is able to scroll. We ensure that at least one line is visible.

I also removed the margins used when the TextEditor is clicked, or the line is being edited. It used a margin of 5px for mouse clicks and a 30px margin when editing text. This helps to maintain the scroll more stable when editing or clicking the textView in the edges.

Some demo:

allow-scroll-below-document.mp4

Fixes #141.

Remove the _documentSize var and directly use the _scrollExtent, like the upstream project. Cleanup commented code.
This commit fixes AllowScrollBelowDocument option. The events chain in the ScrollViewer prevented AvaloniaEdit to reserve more space because when the scrollbar reached the max viewport no new events were send, so the code did not work as WPF.

Instead, I changed the implementation to behave as Visual Studio / Visual Studio Code / Sublime. They basically adds an extra Bounds.Height - minimum distance (tipically one line) when the option is enabled.
and set them to the TextView to cause it to call InvalidateDefaultTextMetrics()
…oll jumps

just align the line top to the view, as other editor do (VS, VSCode, Sublime)
@danipen danipen requested a review from Gillibald September 19, 2022 09:53
@Gillibald Gillibald merged commit 59fb1af into master Sep 19, 2022
@Takoooooo Takoooooo deleted the allow-scroll-below-document branch November 30, 2022 14:26
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.

AvaloniaEdit works incorrectly with every value of AllowScrollBelowDocument
2 participants