-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: when sorting groups, if first element wasn't sorted, it will be moved to previous group #72
Comments
Calsign
added a commit
to AutoPallet/cargo-sort
that referenced
this issue
Dec 20, 2024
…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.
Calsign
added a commit
to AutoPallet/cargo-sort
that referenced
this issue
Dec 20, 2024
…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.
Calsign
added a commit
to AutoPallet/cargo-sort
that referenced
this issue
Dec 20, 2024
…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.
Calsign
added a commit
to AutoPallet/cargo-sort
that referenced
this issue
Dec 20, 2024
…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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When sorting groups, if first element wasn't sorted, it will be moved to previous group.
E.g.:
The text was updated successfully, but these errors were encountered: