Browse Source

Fixed an issue RTL wrapped text calculates an extra line for the control desired size (#17209)

* Always Return 0 bidi level for TextEndOfLine run

* Fix test unit

* Expand the unit test

---------

Co-authored-by: Benedikt Stebner <[email protected]>
Co-authored-by: Julien Lebosquain <[email protected]>
Compunet 1 year ago
parent
commit
e913c895ec

+ 1 - 1
src/Avalonia.Base/Media/TextFormatting/BidiReorderer.cs

@@ -169,7 +169,7 @@ namespace Avalonia.Media.TextFormatting
 
             if (run is TextEndOfLine)
             {
-                return defaultLevel;
+                return 0;
             }
 
             if(previousLevel is not null)

+ 7 - 3
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextFormatterTests.cs

@@ -156,11 +156,15 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
 
                 Assert.Equal(14, textLine.Length);
 
-                var second = textLine.TextRuns[1] as ShapedTextRun;
+                var first = textLine.TextRuns[0] as ShapedTextRun;
 
-                Assert.NotNull(second);
+                var last = textLine.TextRuns[4] as TextEndOfParagraph;
 
-                Assert.Equal("Hello".AsMemory(), second.Text);
+                Assert.NotNull(first);
+
+                Assert.NotNull(last);
+
+                Assert.Equal("Hello".AsMemory(), first.Text);
             }
         }