Browse Source

Fixes requested changes.

BDisp 3 years ago
parent
commit
ef494eecdc
2 changed files with 11 additions and 8 deletions
  1. 1 2
      Terminal.Gui/Views/Checkbox.cs
  2. 10 6
      UnitTests/CheckboxTests.cs

+ 1 - 2
Terminal.Gui/Views/Checkbox.cs

@@ -114,8 +114,7 @@ namespace Terminal.Gui {
 				break;
 			}
 
-			int w = TextFormatter.Size.Width - (TextFormatter.Text.Contains (HotKeySpecifier)
-				? Math.Max (Rune.ColumnWidth (HotKeySpecifier), 0) : 0);
+			int w = TextFormatter.Size.Width - GetHotKeySpecifierLength ();
 			GetCurrentWidth (out int cWidth);
 			var canSetWidth = SetWidth (w, out int rWidth);
 			if (canSetWidth && (cWidth < rWidth || AutoSize)) {

+ 10 - 6
UnitTests/CheckboxTests.cs

@@ -175,6 +175,7 @@ namespace Terminal.Gui.Views {
 				X = 1,
 				Y = Pos.Center (),
 				Text = "Check this out 你",
+				AutoSize = false,
 				Width = 25
 			};
 			var win = new Window () {
@@ -226,8 +227,9 @@ namespace Terminal.Gui.Views {
 				X = 1,
 				Y = Pos.Center (),
 				Text = "Check this out 你",
-				Width = 25,
-				TextAlignment = TextAlignment.Centered
+				TextAlignment = TextAlignment.Centered,
+				AutoSize = false,
+				Width = 25
 			};
 			var win = new Window () {
 				Width = Dim.Fill (),
@@ -278,8 +280,9 @@ namespace Terminal.Gui.Views {
 				X = 1,
 				Y = Pos.Center (),
 				Text = "Check this out 你",
-				Width = 25,
-				TextAlignment = TextAlignment.Justified
+				TextAlignment = TextAlignment.Justified,
+				AutoSize = false,
+				Width = 25
 			};
 			var win = new Window () {
 				Width = Dim.Fill (),
@@ -330,8 +333,9 @@ namespace Terminal.Gui.Views {
 				X = 1,
 				Y = Pos.Center (),
 				Text = "Check this out 你",
-				Width = 25,
-				TextAlignment = TextAlignment.Right
+				TextAlignment = TextAlignment.Right,
+				AutoSize = false,
+				Width = 25
 			};
 			var win = new Window () {
 				Width = Dim.Fill (),