Fix line break enumerator infinite loop - #21808
Conversation
Empty text has no content and should not produce any line break opportunities. Short-circuit in MoveNext before entering the read/rule loop, while keeping the PeekAt EndOfText fix as a defensive safeguard.
|
Isn't the issue that PeekAt does not yield a state that indicates the end of text for empty text? https://github.com/irihitech/Avalonia/blob/703085f4378ae8a1fea8fc58dee5c0825ede4161/src/Avalonia.Base/Media/TextFormatting/Unicode/LineBreakEnumerator.cs#L1639 |
I tried that approach, but the empty string returns true first and then false, which means empty string will generate a line break, I think that's not expected. If that is expected, then I can just mark EndOfText = true, let me know your opinion. |
|
You can test this PR using the following package version. |
Gillibald
left a comment
There was a problem hiding this comment.
LGTM
This is the simplest solution that fixes the issue
* Add failing test: LineBreakEnumerator infinite loop on empty string * Return false immediately for empty string in LineBreakEnumerator Empty text has no content and should not produce any line break opportunities. Short-circuit in MoveNext before entering the read/rule loop, while keeping the PeekAt EndOfText fix as a defensive safeguard.
What does the pull request do?
LineBreakEnumerator now goes to infinite loop when breaking an empty string. This PR resolves this issue.
What is the current behavior?
Infinite loop
What is the updated/expected behavior with this PR?
Immediately returns false when moving next.
How was the solution implemented (if it's not obvious)?
Obvious
Checklist
Breaking changes
No, I don't think anyone is utilizing this feature or bug.
Obsoletions / Deprecations
Fixed issues