Skip to content

Each Array element on a line #782

Answered by epage
beeb asked this question in Q&A
Sep 6, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You'll need to set the Decor for each element to match your desired style.

As an example

fn visit_array_mut(&mut self, node: &mut toml_edit::Array) {
toml_edit::visit_mut::visit_array_mut(self, node);
if !self.multiline_array || (0..=1).contains(&node.len()) {
node.set_trailing("");
node.set_trailing_comma(false);
} else {
for item in node.iter_mut() {
item.decor_mut().set_prefix("\n ");
}
node.set_trailing("\n");
node.set_trailing_comma(true);
}
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@beeb
Comment options

Answer selected by beeb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants