DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.33k stars 736 forks source link

bug: Nested macros don't get formatted properly in CLI `fmt` #2205

Closed marc2332 closed 2 months ago

marc2332 commented 3 months ago

Problem

Big example: image

Smaller repro:

fn app() -> Element {
    rsx!(
        rect {
            height: "50%",
            width: "100%",
            onclick: |_| {
                rsx!(
                    rect {
                        height: "50%",
                        width: "100%",
                        a: "2",
                        b: "3",
                        d: "4",
                        height: "50%",
                        width: "100%",
                        a: "2",
                        b: "3",
                        d: "4",
                    }
                );
            }
        }
    )
}

run dx fmt --file file.rs --split-line-attributes

turns into:

fn app() -> Element {
    rsx!(
        rect {
            height: "50%",
            width: "100%",
            onclick: |_| {
                rsx!(
                    rect { height : "50%", width : "100%", a : "2", b : "3", d : "4", height :
                    "50%", width : "100%", a : "2", b : "3", d : "4", }
                );
            }
        }
    )
}

Expected behavior

Still break the line on nested macros.

Environment: