DioxusLabs / DioxusLabs/dioxus
Component code keeps getting indented further and further on save
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
Not sure of the exact cause of this so I'm filing it here. I'm using VS Code with the extension and dx v0.6.3. This component has one section with very odd indentation. Every time I save the file, the indentation goes further and further right until this particular clause is indented hundreds of spaces. I've seen this behavior a few times now but I don't know what in particular causes it.
I'm including the entire component below. I was able to duplicate this by copy-pasting it into another file and saving. It doesn't need to compile, it just needs to be formatted.
```
#[component]
pub fn ScrollManager(context: String, children: Element) -> Element {
let id = current_scope_id()?;
let id = use_signal(|| format!("scroll_manager_{}", id.0));
let mut stored_position =
use_synced_storage::(format!("scroll_{context}"), || (0, 0));
use_effect(move || {
let ScrollPosition {
x: new_x, y: new_y, ..
} = SCROLL_POSITION();
spawn(async move {
let top: i32 = document::eval(&format!(
r#"
let element = document.getElementById("{id}")
let rect = element.getBoundingClientRect()
return rect.top
"#
))
.join()
.await
.unwrap();
println!("New: {new_y}, Top: {top}");
let new_y = 0.min(new_y - top);
println!("Storing: {new_x}, {new_y}");
*stored_position.write() = (new_x, new_y);
});
});
rsx! {
div {
id,
onmounted: move |_| async move {
let bottom: f64 = document::eval(
&format!(
"
let element = document.getElementById(\"{id}\")
let rect = element.getBoundingClientRect()
return rect.bottom
",
),
)
.join()
.await
.unwrap();
println!("Bottom: {bottom}");
},
{children}
}
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue in VS Code using the supplied component and dx v0.6.3, then save it repeatedly to observe where indentation grows. Compare the formatter output between saves and identify the formatter or extension entry point responsible; done means the component remains consistently indented across repeated saves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100