Skip to content

dx fmt breaks indentation of commented-out RSX blocks (regression since v0.7.3) #5463

@seflue

Description

@seflue

Since v0.7.4 (commit b6793dc, PR #5257), dx fmt mangles the indentation of commented-out RSX blocks. Two variants:

Variant 1: First line keeps indentation, rest gets dedented

Idempotency test with this input fails:

 rsx! {
     div {
         h2 { "Title" }
         // div { class: "wrapper",
-        //     p { "A" }
-        //     p { "B" }
-        // }
+    //     p { "A" }
+    //     p { "B" }
+    // }
     }
 }

Variant 2: Entire block gets dedented (nested rsx!)

 rsx! {
     Component {
         field: rsx! {
             div {
                 h2 { "Title" }
-                // div { class: "wrapper",
-                //     // nested comment
-                //     p { "A" }
-                // }
+            // div { class: "wrapper",
+            //     // nested comment
+            //     p { "A" }
+            // }
             }
         },
     }
 }

Root cause is the rewritten comment-handling in packages/autofmt/src/writer.rs (PR #5257). Commented-out RSX blocks aren't covered by existing tests.

Happy to submit a PR with the test cases (and a fix) if that's helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions