Skip to content

Commit

Permalink
Fix foreach runes bug with unicode surrogate pairs (#3894)
Browse files Browse the repository at this point in the history
  • Loading branch information
tznind authored Jan 12, 2025
1 parent 7676f89 commit 81ad695
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Terminal.Gui/Text/TextFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,7 @@ public static string RemoveHotKeySpecifier (string text, int hotPos, Rune hotKey
var start = string.Empty;
var i = 0;

foreach (Rune c in text)
foreach (Rune c in text.EnumerateRunes ())
{
if (c == hotKeySpecifier && i == hotPos)
{
Expand Down
12 changes: 12 additions & 0 deletions UnitTests/Views/LabelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,4 +1460,16 @@ public void CanFocus_True_MouseClick_Focuses ()
Application.Top.Dispose ();
Application.ResetState ();
}

// https://github.com/gui-cs/Terminal.Gui/issues/3893
[Fact]
[SetupFakeDriver]
public void TestLabelUnderscoreMinus ()
{
var lbl = new Label ()
{
Text = "TextView with some more test_- text. Unicode shouldn't 𝔹Aℝ𝔽!"
};
lbl.Draw ();
}
}

0 comments on commit 81ad695

Please sign in to comment.