This repository was archived by the owner on Aug 31, 2023. It is now read-only.
fix(formatter): Tighten has_line_breaks
method
#2581
Merged
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
has_line_breaks
method is a heuristic for determining if aFormatElement
will break for certain, similar to Prettier'swillBreak
function.This PR changes the function to return
false
forLineSuffix
because a line suffix by itself doesn't introduce a line break. It only delays printing its content until the printer reaches the end of the line. ALineSuffix
forces a group to expand but that only applies if the element is used inside of aGroup
, similar tosoft_line_break
that only expands to a line break outside of a group. That's why this PR changes the semantic to havesoft_line_break
andLineSuffix
aligned.