forked from DevinR528/cargo-sort
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…in a group. DevinR528#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: ```toml [package] name = "foobar" version = "0.1.0" edition = "2021" [dependencies] a = { workspace = true } b = { workspace = true } d = { workspace = true } c = { workspace = true } ``` Current behavior produces the following output: ```toml [package] name = "foobar" version = "0.1.0" edition = "2021" [dependencies] a = { workspace = true } b = { workspace = true } c = { workspace = true } d = { workspace = true } ``` This is because the newline separating the groups is attached to the decor for `d`, and it stays with `d` even as `c` and `d` 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.
- Loading branch information
Showing
3 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "foobar" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
a = { workspace = true } | ||
c = { workspace = true } | ||
b = { workspace = true } | ||
|
||
e = { workspace = true } | ||
d = { workspace = true } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "foobar" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
a = { workspace = true } | ||
b = { workspace = true } | ||
c = { workspace = true } | ||
|
||
d = { workspace = true } | ||
e = { workspace = true } |
This file contains 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