瀏覽代碼

Fixing TextFormatter unit test.

BDisp 5 年之前
父節點
當前提交
805fdeb344
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 1 1
      Terminal.Gui/Core/TextFormatter.cs
  2. 2 2
      UnitTests/TextFormatterTests.cs

+ 1 - 1
Terminal.Gui/Core/TextFormatter.cs

@@ -47,7 +47,7 @@ namespace Terminal.Gui {
 			set {
 				text = value;
 
-				if (Size.Width == 0 || Size.Height == 0 || Size.Width != text.RuneCount) {
+				if (text.RuneCount > 0 && (Size.Width == 0 || Size.Height == 0 || Size.Width != text.RuneCount)) {
 					// Proivde a default size (width = length of longest line, height = 1)
 					// TODO: It might makem more sense for the default to be width = length of first line?
 					Size = new Size (TextFormatter.MaxWidth (Text, int.MaxValue), 1);

+ 2 - 2
UnitTests/TextFormatterTests.cs

@@ -533,8 +533,8 @@ namespace Terminal.Gui {
 		{
 			Assert.Equal (Rect.Empty, TextFormatter.CalcRect (0, 0, null));
 			Assert.Equal (Rect.Empty, TextFormatter.CalcRect (0, 0, ""));
-			Assert.Equal (Rect.Empty, TextFormatter.CalcRect (1, 2, ""));
-			Assert.Equal (Rect.Empty, TextFormatter.CalcRect (-1, -2, ""));
+			Assert.Equal (new Rect (new Point (1, 2), Size.Empty), TextFormatter.CalcRect (1, 2, ""));
+			Assert.Equal (new Rect (new Point (-1, -2), Size.Empty), TextFormatter.CalcRect (-1, -2, ""));
 		}
 
 		[Fact]