Skip to content

Commit 9d5b4c5

Browse files
committed
Replace hardcoded 50 in AllowScrollBelowDocument handling with Caret.MinimumDistanceToViewBorder (unfortunately currently also hardcoded)
1 parent 63b30b7 commit 9d5b4c5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

ICSharpCode.AvalonEdit/Rendering/TextView.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,13 @@ protected override Size MeasureOverride(Size availableSize)
944944
TextEditorOptions options = this.Options;
945945
if (options.AllowScrollBelowDocument) {
946946
if (!double.IsInfinity(scrollViewport.Height)) {
947-
heightTreeHeight = Math.Max(heightTreeHeight, Math.Min(heightTreeHeight - 50, scrollOffset.Y) + scrollViewport.Height);
947+
// HACK: we need to keep at least Caret.MinimumDistanceToViewBorder visible so that we don't scroll back up when the user types after
948+
// scrolling to the very bottom.
949+
double minVisibleDocumentHeight = Math.Max(DefaultLineHeight, Editing.Caret.MinimumDistanceToViewBorder);
950+
// scrollViewportBottom: bottom of scroll view port, but clamped so that at least minVisibleDocumentHeight of the document stays visible.
951+
double scrollViewportBottom = Math.Min(heightTreeHeight - minVisibleDocumentHeight, scrollOffset.Y) + scrollViewport.Height;
952+
// increase the extend height to allow scrolling below the document
953+
heightTreeHeight = Math.Max(heightTreeHeight, scrollViewportBottom);
948954
}
949955
}
950956

0 commit comments

Comments
 (0)