Repository navigation
BUG: Keep the text shown before a change of direction - #4155
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4155 +/- ##
=======================================
Coverage 98.12% 98.12%
=======================================
Files 59 59
Lines 11572 11579 +7
Branches 2161 2162 +1
=======================================
+ Hits 11355 11362 +7
Misses 123 123
Partials 94 94 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
stefan6419846
requested changes
Oct 5, 2026
Contributor
Author
|
Done, it's now |
Contributor
Author
|
Done, I used your wording. |
Contributor
Author
|
Yes, that's only how GitHub renders it. The line is "١٢٣٤ ابحرم", "١٢٣٤ مرحبا" with a plain ", " between the two strings and no direction marks; the browser's bidi algorithm moves the comma when RTL text surrounds it. Running repr() on the line shows the order as written. |
stefan6419846
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4142.
Since 6.19.0, extract_text() drops an Arabic-Indic or Persian number when
it ends a right-to-left line, e.g. "بتاريخ ٢٠٢٦" comes back as "بتاريخ".
The cause is in get_display_str. When the direction switches, the text
collected so far is handed to the visitor and then reset, so it never
reaches the output. #4077 made these digits neutral, so they now collect
before the first Arabic letter of the line and are dropped at the switch.
The same path also dropped Latin text shown before Arabic text in one
operator.
get_display_str now also returns the runs completed by a change of
direction, and the extractor adds them to the output. The visitor still
receives each run exactly once.
This does not reorder runs: the number comes out before the word, in
display order. Logical ordering is #1629, which #4077 also left out.
The new test covers Arabic-Indic and Persian digits before Arabic text,
and Latin text before and after it. The cases fail before the change and
pass after it, and the full suite passes locally.
Used Claude Code (Claude Opus 5.5) to help find and patch this and to draft this description; I reviewed and tested the change.