Browse Source

Combine to one non-destructive mutation

Brandon Thetford 1 year ago
parent
commit
6865391bd1
1 changed files with 6 additions and 7 deletions
  1. 6 7
      Terminal.Gui/Drawing/LineCanvas.cs

+ 6 - 7
Terminal.Gui/Drawing/LineCanvas.cs

@@ -85,14 +85,13 @@ public class LineCanvas : IDisposable
                     bounds = Rectangle.Union (bounds, _lines [i].Bounds);
                 }
 
-                if (bounds.Width == 0)
+                if (bounds is {Width: 0} or {Height: 0})
                 {
-                    bounds.Width = 1;
-                }
-
-                if (bounds.Height == 0)
-                {
-                    bounds.Height = 1;
+                    bounds = bounds with
+                    {
+                        Width = Math.Clamp (bounds.Width, 1, short.MaxValue),
+                        Height = Math.Clamp (bounds.Height, 1, short.MaxValue)
+                    };
                 }
 
                 _cachedBounds = bounds;