Apply visual run resets to line range.#55
Merged
mbrubeck merged 1 commit intoservo:masterfrom Apr 6, 2021
Merged
Conversation
Contributor
|
Thanks! It looks like this increases the minimum Rust requirement to 1.36 because it uses non-lexical lifetimes. I think that's fine, because our main downstream crate ( |
Contributor
|
Published unicode-bidi 0.3.5 with this fix. |
mbrubeck
added a commit
to mbrubeck/rust-unic
that referenced
this pull request
Apr 22, 2021
This fixes a bug where indices within a line are incorrectly used to index within the paragraph. For more details, see: servo/unicode-bidi#55
mbrubeck
added a commit
to mbrubeck/rust-unic
that referenced
this pull request
Apr 22, 2021
This fixes a bug where indices within a line are incorrectly used to index within the paragraph. For more details, see: servo/unicode-bidi#55
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.
The reset logic in visual runs doesn't take the line offset into account. The for loop iterates over the line's char indices, but the line-local index
iis then used to index into theoriginal_classesfor the whole paragraph.Consider the string
"aa טֶ", which consists of five chars with the following subranges:0..1: a1..2: a2..3: space3..5: ט5..7: \u{5b6}What happens in detail: When resolving the line
3..7, the code previously iterated over both chars, and for the last chari=2resolved to the original class of the space, settingreset_fromtoSome(2). Then, all bytes from2toline_str.len()(which was4), were reset to paragraph level. As a result, the first half ofטwas reset to0.The result of all this is that the reordered visual runs now slice the
טin half because its level changes halfway through. In addition to a fix for the problem, I added the above example as a test case.