From 182f11d0f371830751d8cc31ffa6a4c8e39c7d39 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Mon, 19 Dec 2022 16:17:59 -0800 Subject: [PATCH] chore: update with master --- packages/autofmt/src/element.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/autofmt/src/element.rs b/packages/autofmt/src/element.rs index 16b4d8a68..f17aac462 100644 --- a/packages/autofmt/src/element.rs +++ b/packages/autofmt/src/element.rs @@ -298,7 +298,7 @@ impl Buffer { } [BodyNode::RawExpr(ref expr)] => { // TODO: let rawexprs to be inlined - get_expr_length(&expr.expr) + get_expr_length(expr) } [BodyNode::Element(ref el)] => { let attr_len = self.is_short_attrs(&el.attributes); @@ -309,10 +309,10 @@ impl Buffer { if el.children.len() == 1 { if let BodyNode::Text(ref text) = el.children[0] { - if text.text.value().len() + el.name.to_string().len() + attr_len < 80 { - return Some( - text.text.value().len() + el.name.to_string().len() + attr_len, - ); + let value = text.source.as_ref().unwrap().value(); + + if value.len() + el.name.to_string().len() + attr_len < 80 { + return Some(value.len() + el.name.to_string().len() + attr_len); } } } @@ -326,11 +326,15 @@ impl Buffer { for item in items { match item { BodyNode::Component(_) | BodyNode::Element(_) => return None, - BodyNode::Text(text) => total_count += text.text.value().len(), - BodyNode::RawExpr(expr) => match get_expr_length(&expr.expr) { + BodyNode::Text(text) => { + total_count += text.source.as_ref().unwrap().value().len() + } + BodyNode::RawExpr(expr) => match get_expr_length(expr) { Some(len) => total_count += len, None => return None, }, + BodyNode::ForLoop(_) => todo!(), + BodyNode::IfChain(_) => todo!(), } }