Skip to content

Commit 81ad695

Browse files
authored
Fix foreach runes bug with unicode surrogate pairs (#3894)
1 parent 7676f89 commit 81ad695

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Terminal.Gui/Text/TextFormatter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,7 @@ public static string RemoveHotKeySpecifier (string text, int hotPos, Rune hotKey
21242124
var start = string.Empty;
21252125
var i = 0;
21262126

2127-
foreach (Rune c in text)
2127+
foreach (Rune c in text.EnumerateRunes ())
21282128
{
21292129
if (c == hotKeySpecifier && i == hotPos)
21302130
{

UnitTests/Views/LabelTests.cs

+12
Original file line numberDiff line numberDiff line change
@@ -1460,4 +1460,16 @@ public void CanFocus_True_MouseClick_Focuses ()
14601460
Application.Top.Dispose ();
14611461
Application.ResetState ();
14621462
}
1463+
1464+
// https://github.com/gui-cs/Terminal.Gui/issues/3893
1465+
[Fact]
1466+
[SetupFakeDriver]
1467+
public void TestLabelUnderscoreMinus ()
1468+
{
1469+
var lbl = new Label ()
1470+
{
1471+
Text = "TextView with some more test_- text. Unicode shouldn't 𝔹Aℝ𝔽!"
1472+
};
1473+
lbl.Draw ();
1474+
}
14631475
}

0 commit comments

Comments
 (0)