dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

DX format eats comments at the end of blocks

Open RustGrow opened this issue 1 year ago • 4 comments

While creating an app, sometimes you have to comment out nested tags to see the difference. When saving Ctrl + S, all commented tags are deleted. You have to save them outside the component and then re-insert them. This behavior is not logical at all during development and is annoying.

https://github.com/user-attachments/assets/1bfa12ee-5e6b-4cfc-acc5-b4e1fffe9acd

Environment: Dioxus version: dioxus 0.6.0-alpha.2 (https://github.com/DioxusLabs/dioxus/commit/d0c9b6712d22e8fced9f0b0ac253e266d73eb3d1) from github 03/10/24 Rust version: rustc 1.81.0 (eeb90cda1 2024-09-04) OS info: Win11 App platform: web VSCode 1.93.1 (last for 03/10/24) Dioxus VSCode Extension v0.5.1

RustGrow avatar Oct 03 '24 10:10 RustGrow

It's not only at the end of a block.

This works fine when formatted

    rsx! {
        //document::Link { rel: "stylesheet", href: asset!("/public/tailwind.css") }
        div {
            class: "flex flex-col justify-center overflow-hidden py-6 px-2",
            "data-theme": "light",
            div { class: "mx-auto max-w-2xl", Router::<BaseRoute> {} }
        }
    }

Here the comment will get erased during formatting.

   rsx! {
        //document::Link { rel: "stylesheet", href: asset!("/public/tailwind.css") }
        
        div {
            class: "flex flex-col justify-center overflow-hidden py-6 px-2",
            "data-theme": "light",
            div { class: "mx-auto max-w-2xl", Router::<BaseRoute> {} }
        }
    }

leaving

    rsx! {
        div {
            class: "flex flex-col justify-center overflow-hidden py-6 px-2",
            "data-theme": "light",
            div { class: "mx-auto max-w-2xl", Router::<BaseRoute> {} }
        }
    }

This with version 0.5.1 of the extension and 0.6.0-rc.0 of Dioxus.

ochrons avatar Dec 03 '24 20:12 ochrons

It also removes comments from inside event handlers

rsx! {
    button {
        onclick: move |_| {
            let a = Some(5);
            match a {
                // will be removed
                Some(a) => {
                    // will be removed
                    println!("test")
                },
                None => (),
            }
        },
    }
}

v0.6.1

istudyatuni avatar Dec 22 '24 16:12 istudyatuni

If you have some (e.g. not yet compiling) code in an event handler which you comment out to test something else first, all the commented code is being removed. This reduces the (otherwise great!) experience with Dioxus while experimenting and figuring out how things work. A fix would be appreciated very much!

flba-eb avatar Jan 12 '25 16:01 flba-eb

ran into the same issue with the latest version: https://github.com/DioxusLabs/dioxus/issues/4267

pseidemann avatar Jun 11 '25 13:06 pseidemann