mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-30 08:00:21 +00:00
fix comments being eaten in autofmt
This commit is contained in:
parent
a7f0df1507
commit
74421d47fd
4 changed files with 33 additions and 4 deletions
|
@ -126,8 +126,13 @@ impl Buffer {
|
|||
|
||||
pub fn write_body_no_indent(&mut self, children: &[BodyNode]) -> Result {
|
||||
let last_child = children.len();
|
||||
let iter = children.iter().peekable().enumerate();
|
||||
|
||||
for (idx, child) in iter {
|
||||
if self.current_span_is_primary(child.span()) {
|
||||
self.write_comments(child.span())?;
|
||||
}
|
||||
|
||||
for (idx, child) in children.iter().enumerate() {
|
||||
match child {
|
||||
// check if the expr is a short
|
||||
BodyNode::RawExpr { .. } => {
|
||||
|
@ -138,9 +143,6 @@ impl Buffer {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
if self.current_span_is_primary(child.span()) {
|
||||
self.write_comments(child.span())?;
|
||||
}
|
||||
self.tabbed_line()?;
|
||||
self.write_ident(child)?;
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ impl Buffer {
|
|||
if !children.is_empty() {
|
||||
self.write_body_indented(children)?;
|
||||
}
|
||||
|
||||
self.tabbed_line()?;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,3 +30,6 @@ twoway! ("key" => key);
|
|||
|
||||
// Disabled because we can't handle comments on exprs yet
|
||||
twoway! ("multirsx" => multirsx);
|
||||
|
||||
// Disabled because we can't handle comments on exprs yet
|
||||
twoway! ("commentshard" => commentshard);
|
||||
|
|
23
packages/autofmt/tests/samples/commentshard.rsx
Normal file
23
packages/autofmt/tests/samples/commentshard.rsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
rsx! {
|
||||
// Comments
|
||||
div {
|
||||
// Comments
|
||||
class: "asdasd",
|
||||
|
||||
// Comments
|
||||
"hello world",
|
||||
|
||||
// Comments
|
||||
expr1,
|
||||
|
||||
// Comments
|
||||
expr2,
|
||||
|
||||
// Comments
|
||||
// Comments
|
||||
// Comments
|
||||
// Comments
|
||||
// Comments
|
||||
expr3
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue