Closed
Description
Problem
cargo add
does not preserve formatting of TOML lists unrelated to the [dependencies]
table
Steps
With the following Cargo.toml
:
[package]
name = "xxx"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[features]
default = [
"a",
"b",
"c",
]
a = []
b = []
c = []
Run:
$ cargo add directories
Updating crates.io index
Adding directories v4.0.1 to dependencies.
observe that the [features]
table is reformatted:
diff --git i/Cargo.toml w/Cargo.toml
index ccae1b6..61c1383 100644
--- i/Cargo.toml
+++ w/Cargo.toml
@@ -6,13 +6,10 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
+directories = "4.0.1"
[features]
-default = [
- "a",
- "b",
- "c",
-]
+default = ["a", "b", "c"]
a = []
b = []
c = []
Possible Solution(s)
Preserve formatting of all TOML contents outside of the newly added dependency.
Notes
No response
Version
cargo 1.67.1 (8ecd4f20a 2023-01-10)
release: 1.67.1
commit-hash: 8ecd4f20a9efb626975ac18a016d480dc7183d9b
commit-date: 2023-01-10
host: x86_64-apple-darwin
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0 (sys:0.4.59+curl-7.86.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 13.2.1 [64-bit]