Explorar o código

WIP fixing 3469

Tig hai 1 ano
pai
achega
ba4139f5f6

+ 2 - 0
Terminal.Gui/Text/TextFormatter.cs

@@ -198,6 +198,8 @@ public class TextFormatter
             {
                 _size = EnableNeedsFormat (value);
             }
+            Debug.Assert (Size.Width >= 0);
+            Debug.Assert (Size.Height >= 0);
         }
     }
 

+ 2 - 2
Terminal.Gui/View/ViewText.cs

@@ -191,12 +191,12 @@ public partial class View
 
             if (widthAuto is null || !widthAuto._style.HasFlag (Dim.DimAutoStyle.Text))
             {
-                size.Width = _width.Anchor (0);
+                size.Width = ContentSize.Value.Width;
             }
 
             if (heightAuto is null || !heightAuto._style.HasFlag (Dim.DimAutoStyle.Text))
             {
-                size.Height = _height.Anchor (0);
+                size.Height = ContentSize.Value.Height;
             }
 
             // Whenever DimAutoStyle.Text is set, ContentSize will match TextFormatter.Size.

+ 8 - 0
UnitTests/View/Layout/Pos.AnchorEndTests.cs

@@ -303,4 +303,12 @@ public class PosAnchorEndTests (ITestOutputHelper output)
         Assert.Equal (5, result);
     }
 
+    [Fact]
+    public void PosAnchorEnd_MinusOne_Combine_Works ()
+    {
+        var pos = AnchorEnd () - 1;
+        var result = pos.Calculate (10, new DimAbsolute (2), null, Dimension.None);
+        Assert.Equal (7, result);
+
+    }
 }