DioxusLabs / DioxusLabs/dioxus

`dx fmt` result looks minified for rsx tags started deep

Open
#3,591 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**

When using `rsx!` tags deeper in the code (some 4-5 indentation blocks in), `dx fmt` makes some questionable choices in formatting.

It seems like above some indentation / line width, it gives up and just minifies the code like the IOCCC.

![Image](https://github.com/user-attachments/assets/8ede8a54-65ea-4b71-aeb9-90a837a74bc3)

**Steps To Reproduce**

Steps to reproduce the behavior:

- have questionable coding practices
- start `rsx!` tag 5 indentations deep in a component
- put 3 indentations deep rsx code there, see pic below
- `dx fmt`

**Expected behavior**

Normal formatting

**Screenshots**

### Original

![Image](https://github.com/user-attachments/assets/f9a88fec-4b1c-4b41-8b8a-af4e41abca3b)

### After dx fmt

![Image](https://github.com/user-attachments/assets/89ad26c4-2898-4368-9944-ef1453d7acce)

Notice how it's going over the original line length - so i don't think it's doing this out of reaching the line width limit.

### Sample code

```rs
#[component]
pub fn CollectionsAdminListPage() -> Element {
rsx! {
HtmlTable {
data: collections,
title: "Collections",
make_header: move || {
vec![
rsx!("Collection Name"),
rsx!("Collection Title"),
rsx!("Collection Description"),
rsx!("Time Created"),
rsx!("Time Modified"),
rsx!("Actions"),
]
},
make_row: move |c: CollectionUiRow| {
vec![
rsx! {
Link { to : Route::CollectionAdminDetailsPage { collection_id : c
.collection_id.clone() }, "{c.collection_id}" }
},
rsx!("{c.collection_title}"),
rsx!("{c.collection_description}"),
rsx!("{c.time_created}"),
rsx!("{c.time_modified}"),
rsx! {
div { role: "group",
button { "OPEN" }
button {
class: "secondary",
onclick: move |_| {
let c2 = c.clone();
async move {
let _ = drop_collection(c2).await;
do_refresh.call(());
}
},
"DROP"
}
}
},
]
},
}
}
}
```

**Environment:**
- Dioxus version: dioxus 0.6.1 (c2952a7) from binstall
- Rust version: 1.84-nightly
- OS info: linux
- App platform: -

**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.