Ticket #4446 (closed defect: fixed)
Paragraph formatting allows lines one character longer than the margin
Reported by: | proski | Owned by: | andrew_b |
---|---|---|---|
Priority: | major | Milestone: | 4.8.30 |
Component: | mcedit | Version: | master |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | merged | Votes for changeset: | committed-master |
Description
The default word wrap setting is 72 characters, but Alt-P acts as if the setting is 73 characters.
It turns out there is a bug in line_pixel_length(). When xn (the visual width) exceed l (the target width), b (the byte offset in the string and the returnable value) is still incremented before the for loop ends. That's how for loops work. But we want the byte offset after the last character that would fit, i.e. the non-incremented value.
The attached patch moves the increment of the return value to a separate line. The initial increment is not needed, so char_length starts with 0.
I've tested the patch with different charsets, including wide characters.
Attachments
Change History
Changed 23 months ago by proski
- Attachment 0001-Fix-off-by-one-error-in-paragraph-formatting-code.patch added
comment:1 Changed 23 months ago by andrew_b
- Status changed from new to accepted
- Owner set to andrew_b
- Branch state changed from no branch to on review
- Milestone changed from Future Releases to 4.8.30
Thanks!
Branch: 4446_paragraph_format
changeset:44c299c7847e6cb3616a16654dc6a426226a960c
comment:2 Changed 22 months ago by andrew_b
- Votes for changeset set to andrew_b
- Branch state changed from on review to approved
comment:3 Changed 22 months ago by andrew_b
- Status changed from accepted to testing
- Votes for changeset changed from andrew_b to committed-master
- Resolution set to fixed
- Branch state changed from approved to merged
Merged to master: [b1f061e4901028ac7590dba2c1e5d10b48567ecd].
Patch