Fix non-brace delimeters in nested macro formatting (#2831)

This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-08-13 22:47:43 -07:00
1 parent d649b0c54d
commit 851abe82d5
6 files changed
+255 -6

No files matched your search

+6 -1
View File
@@ -1,5 +1,5 @@
use dioxus_rsx::CallBody;
use syn::{parse::Parser, visit_mut::VisitMut, Expr, File, Item};
use syn::{parse::Parser, visit_mut::VisitMut, Expr, File, Item, MacroDelimiter};
use crate::{IndentOptions, Writer};
@@ -46,6 +46,11 @@ pub fn unparse_expr(expr: &Expr, src: &str, cfg: &IndentOptions) -> String {
i.path = syn::parse_str(MARKER).unwrap();
i.tokens = Default::default();
// make sure to transform the delimiter to a brace so the marker can be found
// an alternative approach would be to use multiple different markers that are not
// sensitive to the delimiter.
i.delimiter = MacroDelimiter::Brace(Default::default());
// Push out the indent level of the formatted block if it's multiline
if multiline || formatted.contains('\n') {
formatted = formatted