servo / unicode-bidi

Implementation of the Unicode Bidirection Algorithm in Rust
Other
74 stars 34 forks source link

Fix implementation of L2 in reorder_visual #101

Closed Manishearth closed 1 year ago

Manishearth commented 1 year ago

We were doing this extremely incorrectly: the correct algorithm does multiple overlaid reversals, similar to what we do below in visual_runs (though visual_runs has the benefit of operating on LevelRuns).

The test case this fixes is \u{202D}abc\u{202E}DEF\u{202D}ghi\u{202E}JKL\u{202D}mno, which ought to get reordered as abcghimnoLKJFED, but instead does something different. There's also a simpler testcase in the doctest that already exists (so I didn't add this rather complicated case).