Repository navigation
Conversation
…rinting the right side The newline after `=` was a possible newline that was used when the right side went past the line width, even when the right side would have broken within itself anyway, which it did when formatted again. Now it breaks there when the first line of the right side doesn't fit after it, measured with dprint-core's `fits_on_line_until_first_break`, and otherwise keeps the right side on the line. Like prettier, the right sides that break after their operators and the ones that can't break usefully still break after it, and the line still breaks earlier when it can. Uses dprint-core from the `core-fits-on-line` branch for now.
What's resolved while the printer measures whether something fits on the line is undone, so the member expression's last item line state shouldn't change either. Also updates dprint-core.
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.
Draft: the first slice of the line breaking redesign. It uses dprint-core from dprint/dprint#1424 through
[patch], so it isn't for merging until that's released.The newline after
=was a possible newline, used when the right side went past the line width. That happened even when the right side would have broken within itself anyway, which it did the next time the file was formatted:Now, for variable declarations and assignment expressions, the right side's first line is measured up to where it could break, using
fits_on_line_until_first_break. If it doesn't fit after=, the line breaks after=. Otherwise the right side stays on the line, andKeepLineBeforeHerekeeps a later line that's too long from breaking before it. Like prettier, some right sides still break after the operator:options.value,foo(…).barorx[0] as T), which can only break before that property.When the line could already break earlier (ex. between declarators), it still does, as before. Text printed without newlines, like a trailing comment, doesn't count towards the width.
Testing
main