Skip to content

[Text] Fix RunIndex mapping in BidiReorderer - #22384

Merged
Gillibald merged 3 commits into
AvaloniaUI:mainfrom
niksedk:fix/bidi-reorder-run-index
Oct 5, 2026
Merged

Gillibald merged 3 commits into
AvaloniaUI:mainfrom
niksedk:fix/bidi-reorder-run-index

Conversation

@niksedk

@niksedk niksedk commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

BidiReorder assigned RunIndex to the wrong IndexedTextRun (visual position used as the logical index). This shows with two or more LTR runs inside an RTL line: wrong text bounds, and GetTextBounds throws "Covered length must be greater than zero".

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gillibald Gillibald self-assigned this Oct 4, 2026
@Gillibald Gillibald added bug area-textprocessing backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Oct 4, 2026
- BidiReordererTests: assert RunIndex is the visual position of each logical IndexedTextRun, and that textRuns ends up in visual order, for level sequences that form non-involutive permutations (the old lookup only worked for swaps and reversals).
- TextLayoutTests: splitting runs with style spans must not change line width, per-character bounds or hit-test results, across LTR and RTL paragraphs with mixed Hebrew/Latin/digit text.

@Gillibald Gillibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I have added some more test scenarios to make sure we do not break this in the future. It looks like this was a bug for many years.

@Gillibald
Gillibald enabled auto-merge October 5, 2026 07:19
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

NuGet packages

The packages for this pull request have been published (workflow run):

@Gillibald
Gillibald added this pull request to the merge queue Oct 5, 2026
Merged via the queue into AvaloniaUI:main with commit b76623d Oct 5, 2026
10 checks passed
grokys pushed a commit to Evan260/Avalonia that referenced this pull request Oct 7, 2026
* [Text] Fix RunIndex mapping in BidiReorderer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [Text] Cover BidiReorderer run index mapping at both layers

- BidiReordererTests: assert RunIndex is the visual position of each logical IndexedTextRun, and that textRuns ends up in visual order, for level sequences that form non-involutive permutations (the old lookup only worked for swaps and reversals).
- TextLayoutTests: splitting runs with style spans must not change line width, per-character bounds or hit-test results, across LTR and RTL paragraphs with mixed Hebrew/Latin/digit text.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Benedikt Stebner <Gillibald@users.noreply.github.com>
MrJul pushed a commit that referenced this pull request Oct 9, 2026
* [Text] Fix RunIndex mapping in BidiReorderer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [Text] Cover BidiReorderer run index mapping at both layers

- BidiReordererTests: assert RunIndex is the visual position of each logical IndexedTextRun, and that textRuns ends up in visual order, for level sequences that form non-involutive permutations (the old lookup only worked for swaps and reversals).
- TextLayoutTests: splitting runs with style spans must not change line width, per-character bounds or hit-test results, across LTR and RTL paragraphs with mixed Hebrew/Latin/digit text.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Benedikt Stebner <Gillibald@users.noreply.github.com>
@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants