Skip to content

Commit

Permalink
fix(edit): Ensure all is written
Browse files Browse the repository at this point in the history
Fixes #527
  • Loading branch information
epage committed Mar 8, 2023
1 parent 2a42c64 commit 1c0df12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 4 additions & 2 deletions crates/toml_edit/src/encode.rs
Expand Up @@ -237,11 +237,13 @@ fn visit_nested_tables<'t, F>(
where
F: FnMut(&'t Table, &Vec<&'t Key>, bool) -> Result,
{
callback(table, path, is_array_of_tables)?;
if !table.is_dotted() {
callback(table, path, is_array_of_tables)?;
}

for kv in table.items.values() {
match kv.value {
Item::Table(ref t) if !t.is_dotted() => {
Item::Table(ref t) => {
path.push(&kv.key);
visit_nested_tables(t, path, false, callback)?;
path.pop();
Expand Down
6 changes: 1 addition & 5 deletions crates/toml_edit/tests/testsuite/parse.rs
Expand Up @@ -238,14 +238,10 @@ fn mixed_table_issue_527() {
metadata.msrv = "1.65.0"
[package.metadata.release.pre-release-replacements]
"#;
let expected = r#"
[package]
metadata.msrv = "1.65.0"
"#;
let document = input.parse::<Document>().unwrap();
let actual = document.to_string();
assert_eq(expected, actual);
assert_eq(input, actual);
}

#[test]
Expand Down

0 comments on commit 1c0df12

Please sign in to comment.