Fix #72: --grouped
handling when reording the first entry in a group.
#84
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.
#72
Currently cargo-sort is broken with
--grouped
for situations where the first entry in a group gets reordered within the group, such as the following example:Current behavior produces the following output:
This is because the newline separating the groups is attached to the decor for
d
, and it stays withd
even asc
andd
change places.This doesn't apply to the example above, but it's also possible for this behavior to introduce non-idempotency since the new first item gets attached to the previous group and it may get resorted within that group the next time cargo-sort is run.
I added a test for the correct behavior.