DioxusLabs / DioxusLabs/dioxus

Dx Format incorrect format on rsx macro in a vec macro

Open
#4,106 0 comments 0 reactions 0 assignees View on GitHub
autoformatting bug
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

**Problem**

I came across a bug while I was working with rsx inside of a Vec.
If you nest the rsx macro in the vec macro, any rsx inside the macro won't get formatted. Which isn't ideal, but it's not a major issue.
The problem comes up if the vec macro exists inside another rsx macro, in that case, the inner rsx will get formatted very poorly.

**Steps To Reproduce**

Steps to reproduce the behavior:

- Paste this into your code editor:
```rust
/// Home page
#[component]
fn Home() -> Element {
rsx! {
{
vec![
rsx! {
input {
id: "name",
r#type: "text",
placeholder: "Enter your name",
required: true,
oninput: move |e: Event| {
tracing::debug!("{}", e.value());
},
}
}
];
}
}
}
```
- run dx format
- result looks like this:
```rust
#[component]
fn Home() -> Element {
rsx! {
{
vec![
rsx! {
input { id : "name", r#type : "text", placeholder : "Enter your name",
required : true, oninput : move | e : Event < FormData >| {
tracing::debug!("{}", e.value()); }, }
},
];
}
}
}
```

**Expected behavior**

The inner rsx should get formatted the same way as any other rsx.

**Screenshots**

**Environment:**

- Dioxus version: 0.6.3
- Rust version: 2021
- OS info: Arch Linux
- App platform: web

**Questionnaire**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.