Skip to content

Commit 180c3c8

Browse files
committed
fix(add): Preserve formatting
1 parent 8657668 commit 180c3c8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/cargo/util/toml_mut/manifest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,9 @@ fn fix_feature_activations(
516516
} = parsed_value
517517
{
518518
if dep_name == dep_key && weak {
519-
*value = format!("{dep_name}/{dep_feature}").into();
519+
let mut new_value = toml_edit::Value::from(format!("{dep_name}/{dep_feature}"));
520+
*new_value.decor_mut() = value.decor().clone();
521+
*value = new_value;
520522
}
521523
}
522524
}

tests/testsuite/cargo_add/preserve_features_table/out/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ default = [
1414
"b",
1515
"c",
1616
]
17-
a = ["your-face/nose", # but not the mouth and nose
17+
a = [
18+
"your-face/nose", # but not the mouth and nose
1819
]
1920
b = []
2021
c = []

0 commit comments

Comments
 (0)