Avoid the accidental removal of comments inside expressions by dx fmt (#4410)
* Avoid the accidental removal of comments inside expressions by dx fmt * Rewrite the logic to pass failed tests * Removed unnecessary call to write_inline_comments * add failing test case * alter parsing a bit to handle more test cases * almost there... * fix * use threadlocal --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
88c693b2e4
commit
54d465a7b5
7 files changed
+213
-21
No files matched your search
@@ -121,6 +121,109 @@ rsx! {
|
||||
// Please dont eat me 2
|
||||
}
|
||||
|
||||
div {
|
||||
{
|
||||
// Please dont eat me 1
|
||||
let millis = timer
|
||||
.with(|t| {
|
||||
t.duration()
|
||||
.saturating_sub(
|
||||
t.started_at.map(|x| x.elapsed()).unwrap_or(Duration::ZERO),
|
||||
)
|
||||
.as_millis()
|
||||
});
|
||||
|
||||
// Please dont eat me 2
|
||||
format!(
|
||||
"{:02}:{:02}:{:02}.{:01}",
|
||||
millis / 1000 / 3600 % 3600, // Please dont eat me 3
|
||||
millis / 1000 / 60 % 60,
|
||||
millis / 1000 % 60,
|
||||
|
||||
// Please dont eat me 4
|
||||
millis / 100 % 10,
|
||||
);
|
||||
|
||||
// booo //
|
||||
let b = { yay };
|
||||
|
||||
// boo // boo
|
||||
let a = {
|
||||
let a = "123 // boo 123";
|
||||
// boo // boo
|
||||
asdb
|
||||
};
|
||||
|
||||
format!("{b} {a}")
|
||||
// ennd
|
||||
}
|
||||
}
|
||||
|
||||
div {
|
||||
// booo //
|
||||
{yay}
|
||||
|
||||
// boo // boo
|
||||
{
|
||||
let a = "123 // boo 123";
|
||||
// boo // boo
|
||||
rsx! { "{a}" }
|
||||
}
|
||||
}
|
||||
|
||||
div {
|
||||
input {
|
||||
r#type: "number",
|
||||
min: 0,
|
||||
max: 99,
|
||||
value: format!("{:02}", timer.read().hours),
|
||||
oninput: move |e| {
|
||||
// A comment inside an expression
|
||||
timer.write().hours = e.value().parse().unwrap_or(0);
|
||||
},
|
||||
}
|
||||
|
||||
input {
|
||||
r#type: "number",
|
||||
min: 0,
|
||||
max: 59,
|
||||
value: format!("{:02}", timer.read().minutes),
|
||||
oninput: move |e| {
|
||||
// A comment inside an expression
|
||||
timer.write().minutes = e.value().parse().unwrap_or(0);
|
||||
|
||||
// A comment inside an expression
|
||||
},
|
||||
}
|
||||
|
||||
input {
|
||||
r#type: "number",
|
||||
min: 0,
|
||||
max: 59,
|
||||
value: format!("{:02}", timer.read().seconds),
|
||||
oninput: move |e| {
|
||||
// A comment inside an expression
|
||||
timer.write().seconds = e.value().parse().unwrap_or(0);
|
||||
// A comment inside an expression
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
rsx! { "{a}" }
|
||||
}
|
||||
|
||||
{
|
||||
rsx! { "one" }
|
||||
}
|
||||
|
||||
div {}
|
||||
|
||||
{
|
||||
rsx! { "one two three" }
|
||||
}
|
||||
|
||||
|
||||
// Please dont eat me 1
|
||||
//
|
||||
// Please dont eat me 2
|
||||
|
||||
@@ -148,6 +148,7 @@ fn app() -> Element {
|
||||
value: format!("{:02}", timer.read().seconds),
|
||||
oninput: move |e| {
|
||||
timer.write().seconds = e.value().parse().unwrap_or(0);
|
||||
// A comment inside an expression
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user