Skip to content

Commit

Permalink
fix: don't strip trailing comment between last node and macro closing…
Browse files Browse the repository at this point in the history
… delimiter
  • Loading branch information
bram209 committed Feb 3, 2025
1 parent e17a74f commit d0cd68f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions formatter/src/formatter/mac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ impl Formatter<'_> {
}

self.trim_whitespace(nodes.first().span().start().line - 1);
self.view_macro_nodes(nodes);
self.view_macro_nodes(nodes, view_mac.mac.span());
self.printer.word("}");
self.printer.end();
}

fn view_macro_nodes(&mut self, nodes: &[Node]) {
fn view_macro_nodes(&mut self, nodes: &[Node], mac_span: Span) {
self.printer.cbox_indent();
self.printer.space();

Expand All @@ -130,6 +130,7 @@ impl Formatter<'_> {
}

self.printer.space();
self.flush_comments(mac_span.end().line - 1, true);
self.printer.end_dedent();
}
}
Expand Down
5 changes: 4 additions & 1 deletion formatter/src/source_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ mod tests {
// and some more
// on the next line
</div> };
</div>
// trailing comment
};
}
// comment after view macro
Expand Down Expand Up @@ -412,6 +414,7 @@ mod tests {
// and some more
// on the next line
</div>
// trailing comment
};
}
Expand Down

0 comments on commit d0cd68f

Please sign in to comment.