Tig преди 1 година
родител
ревизия
ba4139f5f6
променени са 3 файла, в които са добавени 12 реда и са изтрити 2 реда
  1. 2 0
      Terminal.Gui/Text/TextFormatter.cs
  2. 2 2
      Terminal.Gui/View/ViewText.cs
  3. 8 0
      UnitTests/View/Layout/Pos.AnchorEndTests.cs

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

@@ -198,6 +198,8 @@ public class TextFormatter
             {
             {
                 _size = EnableNeedsFormat (value);
                 _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))
             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))
             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.
             // 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);
         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);
+
+    }
 }
 }