-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix and simplify unjustify
, remove LineData::alignment
#271
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit awkward, but it seems reasonable. If it fixes unjustify
then I'm happy for it to be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it fixes and simplifies things, it makes sense to merge this, but the whole idea of 'unjustifying' text feels somewhat wrong to me.
`unjustify` doesn't mirror `align`, so it performs the wrong calculations, and re-line-breaking or re-aligning currently lead to the wrong result after a justified alignment. As it's the alignment function requires further iteration (e.g. for floated boxes), this patch removes the specialized `unjustify` implementation and instead uses the same code for aligning and unjustifying. This is a tradeoff between efficiency and correctness. If this is merged in, we can always split the two again in the future once alignment has stabilized. This stores the width the layout was aligned to, which is necessary for unjustifying.
Agreed with both comments. Doing it a different way has some tradeoffs: I think it would either require more memory even if justified alignment is not used (e.g., adding another field like |
unjustify
doesn't mirroralign
, so it performs the wrong calculations, and re-line-breaking or re-aligning currently lead to the wrong result after a justified alignment.As the alignment function requires further iteration (e.g. for floated boxes), this patch removes the specialized
unjustify
implementation and instead uses the same code for aligning and unjustifying. This is a trade-off between efficiency and correctness. If this is merged in, we can always split the two again in the future once alignment has stabilized.This stores the width the layout was aligned to, which is necessary for unjustifying.