Giter VIP home page Giter VIP logo

Comments (8)

DogeDark avatar DogeDark commented on September 27, 2024 1

I can reproduce it now. The formatter doesn't like inline comments and removes them completely:

rsx! {
    div {   // this comment will be removed
        "hi",
    }
}

from dioxus.

DogeDark avatar DogeDark commented on September 27, 2024

I am unable to reproduce this using the git version of the CLI. Can you test the git version of the CLI on your end?

You can install the git version with:

cargo install --git https://github.com/DioxusLabs/dioxus dioxus-cli

from dioxus.

magikmw avatar magikmw commented on September 27, 2024

I did run the command to install git version and checked again:

-                // TODO: Implement event handling here -> listen to eve
nts in child
                 let accept_keys = [Key::Enter, Key::Character(" ".to_string())];
-                if accept_keys.contains(&evt.key()){
+                if accept_keys.contains(&evt.key()) {
                     log::info!("{} pressed in {}", evt.key(), "{props.labelText}");
                     log::info!("{} pressed in {}", evt.key(), "{props.labelText}");
                 }
             },
             class: "flex flex-1 h-full w-3/4 items-center justify-center btn btn-outline my-1 py-1",
-            div { class: "flex-none py-1", // TODO: Refactor into separate component
+            div { class: "flex-none py-1",
                 Icon { width: 24, height: 24, icon: props.icon, title: "{props.iconTitle}" }
-            },
+            }
             "{props.labelText}"
-            input { // TODO: Refactor into separate component
+            input {

dx -V says:

dioxus 0.5.2

from dioxus.

spookyvision avatar spookyvision commented on September 27, 2024

this also seems to affect the VSCode Dioxus extension. Block-level comments (/* .. */) are also affected; doc comments (///) however are not.

from dioxus.

DogeDark avatar DogeDark commented on September 27, 2024

Adding to the list.

All comments are removed in event handlers (except doc comments):

rsx! {
    div {
        // also occurs in move || async move
        onclick: move |_| {
            // is removed
            /* is removed */
        }
    }
}

from dioxus.

OlivierLemoine avatar OlivierLemoine commented on September 27, 2024

I think it comes from here:

fn format_rust(input: &str) -> Result<String> {
let syntax_tree = syn::parse_file(input).map_err(format_syn_error)?;
let output = prettyplease::unparse(&syntax_tree);
Ok(output)
}

syn does not keep comments.

https://crates.io/crates/rustfmt-wrapper (or spawning rustfmt directly) could be used instead.
This won't help in non-rust code, but I think it's a start.

I don't know if Dioxus developers would agree with this solution, but if they do, I would be happy to do it.

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on September 27, 2024

We try our best to preserve comments by writing out whitepace on rsx indents, but there's no way to preserve whitespace with prettyplease. I'd be interested in supporting the rustfmt wrapper approach, but it is convenient for autoformatting to not rely on rustfmt so we can use it in things like wasm.

from dioxus.

OlivierLemoine avatar OlivierLemoine commented on September 27, 2024

What if it was behind a target cfg? Wasi support spawning new tasks, so rustfmt would work.
But it's true it's not an ideal solution.

from dioxus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.