Skip to content

Commit 928d859

Browse files
committed
fix(TextView): Clamp FirstVisibleLine
instead of effectively displaying nothing
1 parent 02a2aca commit 928d859

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Project/Src/Gui/TextView.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ public int FirstVisibleLine
4343
get => textArea.Document.GetFirstLogicalLine(textArea.VirtualTop.Y/FontHeight);
4444
set
4545
{
46-
if (FirstVisibleLine != value)
47-
textArea.VirtualTop = new Point(textArea.VirtualTop.X, textArea.Document.GetVisibleLine(value)*FontHeight);
46+
int clampedValue = Math.Max(0, Math.Min(value, textArea.Document.TotalNumberOfLines - textArea.TextView.VisibleLineCount + 1));
47+
if (FirstVisibleLine != clampedValue)
48+
textArea.VirtualTop = new Point(textArea.VirtualTop.X, textArea.Document.GetVisibleLine(clampedValue) * FontHeight);
4849
}
4950
}
5051

0 commit comments

Comments
 (0)