DevinR528 / cargo-sort

Check if tables and items in a .toml file are lexically sorted
202 stars 28 forks source link

Reordering of sections doesn't add a new line between them #35

Open palfrey opened 2 years ago

palfrey commented 2 years ago

With Cargo.toml as

[dependencies]
amq-protocol = "6"
anyhow = "1"
bytes = "1"
diesel = { version = "1.4", features = ["postgres"] }
dotenv = "0.15.0"
lazy_static = "1"
regex = "1"
serde = "1"
tokio = {version="1", features=["net", "io-util", "rt", "macros", "rt-multi-thread"] }

[dev-dependencies]
celery = "0.4.0-rcn.11"
simplelog = "*"

[package]
edition = "2021"
name = "cavalcade"
version = "0.1.0"

and tomlfmt.toml as

table_order = ["package", "dependencies", "dev-dependencies"]

it gets reordered to


[package]
edition = "2021"
name = "cavalcade"
version = "0.1.0"
[dependencies]
amq-protocol = "6"
anyhow = "1"
bytes = "1"
diesel = { version = "1.4", features = ["postgres"] }
dotenv = "0.15.0"
lazy_static = "1"
regex = "1"
serde = "1"
tokio = { version = "1", features = ["net", "io-util", "rt", "macros", "rt-multi-thread"] }

[dev-dependencies]
celery = "0.4.0-rcn.11"
simplelog = "*"

Note the newline at the top of the file, and the lack of newline before dependencies

palfrey commented 2 years ago

Fixing this manually is easy and the tool is happy after that, so thanks for making it though!

DevinR528 commented 2 years ago

Thanks for catching this, it may be easy to fix but it should work :smile:

I'll look into it unless you are interested?

palfrey commented 2 years ago

I'm unlikely to pick this up any time soon as I've got too many other things on my plate currently.