You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some slightly more complicated examples too. Suppose we have this snippet
let fallback = |errors:RwSignal<Errors>| {view!{// Removed
<div class="error">
// Kept
<p>"Not a number! Errors: "</p>
// Kept
<ul>
// Kept{move || {// Kept, but moved 1
errors
.get().into_iter()// Kept, but moved 2.map(|(_, e)| view! { <li>{e.to_string()}</li> }).collect_view()}}
</ul>
</div>
}};
When I format it, it becomes
let fallback = |errors:RwSignal<Errors>| {view!{
<div class="error">
// Kept
<p>"Not a number! Errors: "</p>
// Kept
<ul>
// Kept{move || {
errors
.get().into_iter().map(|(_, e)| {
view! {// Kept, but moved 1// Kept, but moved 2
<li>{e.to_string()}</li>
}}).collect_view()}}
</ul>
</div>
}};
One comment is removed and two are moved. However this behavior is slightly different when this code is inlined instead of being assigned to a variable.
If I try inlining the above example, the behavior is slightly different
view!{
<h1>"Error Handling"</h1>
<label>
"Type a number (or something that's not a number!) " <input on:input=on_input/>
// the fallback receives a signal containing current errors
<ErrorBoundary fallback=|errors|
view! {// Removed
<div class="error">
// Kept
<p>"Not a number! Errors: "</p>
// Kept
<ul>
// Kept{move || {// Kept, but moved 1
errors
.get().into_iter()// Kept, but moved 2.map(|(_, e)| view! { <li>{e.to_string()}</li> }).collect_view()}}
</ul>
</div>
}
>
<p>"You entered " <strong>{value}</strong></p>
</ErrorBoundary>
</label>
}
The above is formatted into this
view!{
<h1>"Error Handling"</h1>
<label>
"Type a number (or something that's not a number!) " <input on:input=on_input/>
// the fallback receives a signal containing current errors
<ErrorBoundary fallback=|errors| {
view! {// Removed
<div class="error">
// Kept
<p>"Not a number! Errors: "</p>
// Kept
<ul>
// Kept{move || {
errors
.get().into_iter().map(|(_, e)| {
view! {// Kept, but moved 1// Kept, but moved 2
<li>{e.to_string()}</li>
}}).collect_view()}}
</ul>
</div>
}}>
<p>"You entered " <strong>{value}</strong></p>
</ErrorBoundary>
</label>
}
Noticeably the Removed comment is not removed, but the other two are still moved.
Finally here's one example where the formatter actually breaks the code if I have an invalid doc comment
view!{
<h1>"Error Handling"</h1>
<label>
"Type a number (or something that's not a number!) " <input on:input=on_input/>
// the fallback receives a signal containing current errors
<ErrorBoundary fallback=|errors|
view! {
<div class="error">
<p>"Not a number! Errors: "</p>
<ul>
{move || {
errors
.get().into_iter()/// I am invalid.map(|(_, e)| view! { <li>{e.to_string()}</li> }).collect_view()}}
</ul>
</div>
}
>
<p>"You entered " <strong>{value}</strong></p>
</ErrorBoundary>
</label>
}
This is formatted into
view!{
<h1>"Error Handling"</h1>
<label>
"Type a number (or something that's not a number!) " <input on:input=on_input/>
// the fallback receives a signal containing current errors
<ErrorBoundary fallback=|errors| {
view! {
< div class = "error" > < p > "Not a number! Errors: " </ p > < ul > { move || {
errors.get().into_iter() #[doc = " I am invalid"].map(| (_, e) | view! { < li >
{ e.to_string()} </ li > }).collect_view()}} </ ul > </ div >
}}>
<p>"You entered " <strong>{value}</strong></p>
</ErrorBoundary>
</label>
}
Here are my versions
key
value
rustc
1.73.0-nightly (d12c6e947 2023-08-01)
leptos
0.5.0-alpha
leptosfmt
0.1.12
The text was updated successfully, but these errors were encountered:
Hi, we currently don't support non-doc comments in code blocks. We use prettyplease for formatting rust code and it does not support this. I have a fork that I would like to not diverge too much (so I can easily keep in sync with upstream), therefore I didn't add non-doc comment support in my prettyplease fork for now.
I should probably clarify this in the documentation though.
Apologies in advance for the long post, I just don't know if I can demonstrate the issue without these examples.
Suppose we have the following snippet
When I run
leptosfmt myfile
, it removes my// Removed
comment, no matter how long it is or how many lines it spansHowever if I turn
// Removed
into a doc comment, it remains, but I get a clippy warning for an unused doc commentThere are some slightly more complicated examples too. Suppose we have this snippet
When I format it, it becomes
One comment is removed and two are moved. However this behavior is slightly different when this code is inlined instead of being assigned to a variable.
If I try inlining the above example, the behavior is slightly different
The above is formatted into this
Noticeably the
Removed
comment is not removed, but the other two are still moved.Finally here's one example where the formatter actually breaks the code if I have an invalid doc comment
This is formatted into
Here are my versions
The text was updated successfully, but these errors were encountered: