Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ public static void RecalculateSpanPositions(this TextView textView, Label elemen
var spanStartX = (int)layout.GetPrimaryHorizontal(startOffset);

var endOffset = (curLine == spanEndLine) ? spanEndOffset : lineVisibleEndOffset;
var spanEndX = (int)layout.GetSecondaryHorizontal(endOffset);
var validEndOffset = System.Math.Min(endOffset, layout.GetLineEnd(curLine));
var spanEndX = (int)layout.GetSecondaryHorizontal(validEndOffset);

var spanWidth = spanEndX - spanStartX;
var spanLeftX = spanStartX;
Expand Down
40 changes: 40 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25836.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.ComponentModel;
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
using Entry = Microsoft.Maui.Controls.Entry;

namespace Maui.Controls.Sample.Issues
{

[Issue(IssueTracker.Github, 25836, "Span with tail truncation and paragraph breaks with exception", PlatformAffected.Android)]
public class Issue25836 : ContentPage
{
public Issue25836()
{
var span = new Span
{
Text =
" Mi augue molestie ligula lobortis enim Velit, in. \n Imperdiet eu dignissim odio. Massa erat Hac inceptos facilisis nibh " +
" Interdum massa Consectetuer risus sociis molestie facilisi enim. Class gravida. \n Gravida sociosqu cras Quam velit, suspendisse" +
" leo auctor odio integer primis dui potenti dolor faucibus augue justo morbi ornare sem. "
};

var formattedString = new FormattedString();
formattedString.Spans.Add(span);

var label = new Label
{
AutomationId = "Label",
LineBreakMode = LineBreakMode.TailTruncation,
VerticalOptions = LayoutOptions.Start,
FormattedText = formattedString,
MaxLines = 3
};

var layout = new StackLayout();
layout.Children.Add(label);

Content = layout;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue25836 : _IssuesUITest
{
public Issue25836(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Span with tail truncation and paragraph breaks with exception";

[Test]
[Category(UITestCategories.Label)]
public void ExceptionShouldNotBeThrown()
{
App.WaitForElement("Label");
}
}
}