Repository navigation
Keep the last word of a paragraph within its column - #1886
Open
docteurzoidberg wants to merge 1 commit into
Open
docteurzoidberg wants to merge 1 commit into
docteurzoidberg wants to merge 1 commit into
Conversation
When the last word of a paragraph does not fit on the current line, the wrapper emitted two lines in a row (the current one, then the word alone) and only checked the available height after the second. When the first one filled the column or the page, the word was drawn one line below its bottom: past the `height` of the text, under the bottom margin, or over whatever follows. Check the height between the two lines too, with the same logic as after every line, moved to a helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What kind of change does this PR introduce?
Bug fix: the last word of a paragraph could be drawn one line below the bottom of its column or page.
When the last word of a paragraph (the word before a
\n) does not fit on the current line,LineWrapper#wrapemits two lines in a row: the current line, then the word alone. It only checks the available height after the second one. If the first line already filled the column, the word is drawn one line too low. Depending on the layout, it ends up past the text'sheight, under the bottom margin, or over whatever is drawn below the text. The text that follows then starts in the next column as usual, so the columns also come out unbalanced.The fix checks the height between the two lines as well. The existing check that runs after every line is moved to a small helper, so both places share it: the word moves to the next column or page, and is left out when the text has a
heightand no column remains, as any other line would be.Checklist:
tests/unit/line_wrapper.spec.js: next column, new page; both fail without the fix)yarn test(697 tests),yarn lintandprettier --checkpass.