fix(autofmt): add support for handling comments in various expression types (#5461)
* fix(autofmt): add support for handling comments in various expression types * fmt
This commit is contained in:
1 parent
689e39b3f6
commit
c73dc43233
6 files changed
+164
-4
No files matched your search
@@ -0,0 +1,10 @@
|
||||
rsx! {
|
||||
button {
|
||||
class: "control-button",
|
||||
onclick: move |_| async move {
|
||||
// comment
|
||||
()
|
||||
},
|
||||
"print content"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
rsx! {
|
||||
Component {
|
||||
label: {
|
||||
let url = "https://example.com";
|
||||
|
||||
// comment before formatted tail expr
|
||||
format!("{url}/docs")
|
||||
},
|
||||
}
|
||||
|
||||
Component {
|
||||
status: {
|
||||
// comment before branch
|
||||
if is_ready() {
|
||||
"ready"
|
||||
} else {
|
||||
"waiting"
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
div {
|
||||
data_mode: {
|
||||
// comment before block expr
|
||||
if is_ready() {
|
||||
"ready"
|
||||
} else {
|
||||
"waiting"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
rsx! {
|
||||
button {
|
||||
onclick: move |_| async move {
|
||||
let url = "https://example.com";
|
||||
|
||||
// keep this comment with the block, not the string literal
|
||||
println!("{url}");
|
||||
},
|
||||
"strings"
|
||||
}
|
||||
|
||||
Component {
|
||||
message: {
|
||||
let prefix = "value://";
|
||||
|
||||
// comment before final expression that contains //
|
||||
format!("{prefix}done")
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
rsx! {
|
||||
button {
|
||||
onclick: move |_| async move {
|
||||
let nested = move || {
|
||||
// nested closure comment
|
||||
()
|
||||
};
|
||||
|
||||
nested();
|
||||
},
|
||||
"nested closure"
|
||||
}
|
||||
|
||||
button {
|
||||
onclick: move |_| async move {
|
||||
let nested = move || async move {
|
||||
// nested async closure comment
|
||||
()
|
||||
};
|
||||
|
||||
nested().await;
|
||||
},
|
||||
"nested async closure"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user