Don't drop comments in collection literals with preserved newlines. #1587
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.
A line comment in a collection literal triggers special formatting where we allow multiple elements in a single line, like:
The formatter models that by having a DelimitedListBuilder for the entire collection literal. Then the elements that should be packed onto a single line are formatted using a separate DelimitedListBuilder for each line.
In the very rare case where you have a comment after the last element on a line but before the subsequent comma, the comment would get dropped. This is because the comment was sitting in the inner DelimitedListBuilder for the line waiting to be put somewhere, but we then discard that builder to start a new line or when the whole list is done.
This fixes that. Whenever we're done with a line, we hoist any remaining comments up to the outer DelimitedListBuilder. That way the comment gets put after the comma at the end of the line.
Also bump the min SDK constraint to 3.4.0. I don't think dart_style works with an older version because of analyzer's SDK constraints.
Fix #1584.