Browse Source

Ensure the Position is valid if the slider is at end.

BDisp 1 year ago
parent
commit
30be0524e4
1 changed files with 7 additions and 0 deletions
  1. 7 0
      Terminal.Gui/Views/Scroll.cs

+ 7 - 0
Terminal.Gui/Views/Scroll.cs

@@ -147,6 +147,13 @@ public class Scroll : View
 
         int barSize = Orientation == Orientation.Vertical ? ContentSize.Height : ContentSize.Width;
 
+        // Ensure the Position is valid if the slider is at end
+        if ((Orientation == Orientation.Vertical && location + _slider.Frame.Height == barSize)
+            || (Orientation == Orientation.Horizontal && location + _slider.Frame.Width == barSize))
+        {
+            return Size - barSize;
+        }
+
         return Math.Min (location * Size / barSize, Size - barSize);
     }