Fixes #4387. Runes should not be used on a cell, but rather should use a single grapheme rendering 1 or 2 columns (#4388)

* Fixes #4382. StringExtensions.GetColumns method should only return the total text width and not the sum of all runes width

* Trying to fix unit test error

* Update StringExtensions.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Resolving merge conflicts

* Prevents Runes throwing if Grapheme is null

* Add unit test to prove that null and empty string doesn't not throws anything.

* Fix unit test failure

* Fix IsValidLocation for wide graphemes

* Add more combining

* Prevent set invalid graphemes

* Fix unit tests

* Grapheme doesn't support invalid code points like lone surrogates

* Fixes more unit tests

* Fix unit test

* Seems all test are fixed now

* Adjust CharMap scenario with graphemes

* Upgrade Wcwidth to version 4.0.0

* Reformat

* Trying fix CheckDefaultState assertion

* Revert "Trying fix CheckDefaultState assertion"

This reverts commit c9b46b796a.

* Forgot to include driver.End in the test

* Reapply "Trying fix CheckDefaultState assertion"

This reverts commit 1060ac9b63.

* Remove ToString

* Fix merge errors

* Change to conditional expression

* Assertion to prove that no exception throws during cell initialization.

* Remove unnecessary assignment

* Remove assignment to end

* Replace string concatenation with 'StringBuilder'.

* Replace more string concatenation with 'StringBuilder'

* Remove redundant call to 'ToString' because Rune cast to a String object.

* Replace foreach loop with Sum linq

---------

Co-authored-by: Tig <tig@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
BDisp
2025-11-20 18:45:13 +00:00
committed by GitHub
parent 726b15dd28
commit cd75a20c60
53 changed files with 2654 additions and 2145 deletions

View File

@@ -80,10 +80,10 @@ public class ViewDrawTextAndLineCanvasTests () : FakeDriverBase
// Text should appear at the content location
Point screenPos = view.ContentToScreen (Point.Empty);
Assert.Equal ('T', (char)driver.Contents [screenPos.Y, screenPos.X].Rune.Value);
Assert.Equal ('e', (char)driver.Contents [screenPos.Y, screenPos.X + 1].Rune.Value);
Assert.Equal ('s', (char)driver.Contents [screenPos.Y, screenPos.X + 2].Rune.Value);
Assert.Equal ('t', (char)driver.Contents [screenPos.Y, screenPos.X + 3].Rune.Value);
Assert.Equal ("T", driver.Contents [screenPos.Y, screenPos.X].Grapheme);
Assert.Equal ("e", driver.Contents [screenPos.Y, screenPos.X + 1].Grapheme);
Assert.Equal ("s", driver.Contents [screenPos.Y, screenPos.X + 2].Grapheme);
Assert.Equal ("t", driver.Contents [screenPos.Y, screenPos.X + 3].Grapheme);
}
[Fact]
@@ -273,7 +273,7 @@ public class ViewDrawTextAndLineCanvasTests () : FakeDriverBase
// Verify the line was drawn (check for horizontal line character)
for (int i = 0; i < 5; i++)
{
Assert.NotEqual (new Rune (' '), driver.Contents [screenPos.Y, screenPos.X + i].Rune);
Assert.NotEqual (" ", driver.Contents [screenPos.Y, screenPos.X + i].Grapheme);
}
}
@@ -409,7 +409,7 @@ public class ViewDrawTextAndLineCanvasTests () : FakeDriverBase
bool lineRendered = true;
for (int i = 0; i < 5; i++)
{
if (driver.Contents [screenPos.Y, screenPos.X + i].Rune.Value == ' ')
if (driver.Contents [screenPos.Y, screenPos.X + i].Grapheme == " ")
{
lineRendered = false;
break;