From ef494eecdc1f5d11d5e0713727d25cef321c7063 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 18 Jun 2022 02:15:32 +0100 Subject: [PATCH] Fixes requested changes. --- Terminal.Gui/Views/Checkbox.cs | 3 +-- UnitTests/CheckboxTests.cs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Terminal.Gui/Views/Checkbox.cs b/Terminal.Gui/Views/Checkbox.cs index c61cbfad4..9108283c1 100644 --- a/Terminal.Gui/Views/Checkbox.cs +++ b/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)) { diff --git a/UnitTests/CheckboxTests.cs b/UnitTests/CheckboxTests.cs index 0f8d5c7ec..b25aecb94 100644 --- a/UnitTests/CheckboxTests.cs +++ b/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 (),