fix(toml_edit): reformat dotted keyed-items in TableLike::fmt

`TableLike::fmt` only reset the decor of value items, leaving dotted
keyed-items untouched. They are stored as dotted tables and dotted
inline tables, so recurse into them to reformat their key segments and
nested values as well.

Fixes #262
This commit is contained in:
dualfroz committed 2026-09-02 11:42:16 +02:00
1 parent 9f7a403e88
commit 6572de03e2
3 files changed
+70 -18

No files matched your search

+38
View File
@@ -1238,6 +1238,44 @@ fn test_format_array() {
"#]]);
}
#[test]
fn test_format_dotted_keys() {
given(
r#"
a . b = 1
c = 2
d . e . f = 3
"#,
)
.running(|root| {
root.fmt();
})
.produces_display(str![[r#"
a.b = 1
c = 2
d.e.f = 3
"#]]);
}
#[test]
fn test_format_dotted_keys_in_inline_table() {
given(
r#"
a = { b . c = 1, d = 2 }
"#,
)
.running(|root| {
let a = root.get_mut("a").unwrap().as_inline_table_mut().unwrap();
a.fmt();
})
.produces_display(str![[r#"
a = { b.c = 1, d = 2 }
"#]]);
}
macro_rules! as_inline_table {
($entry:ident) => {{
assert!($entry.is_value());