wip: add whitespace parsing to rsx
This commit is contained in:
1 parent
5313fc0cc6
commit
181a51a63b
14 files changed
+278
-24
No files matched your search
@@ -276,7 +276,7 @@ impl Buffer {
|
||||
}
|
||||
|
||||
match children {
|
||||
[BodyNode::Text(ref text)] => Some(text.value().len()),
|
||||
[BodyNode::Text(ref text)] => Some(text.text.value().len()),
|
||||
[BodyNode::Component(ref comp)] => {
|
||||
let attr_len = self.field_len(&comp.fields, &comp.manual_props);
|
||||
|
||||
@@ -290,7 +290,7 @@ impl Buffer {
|
||||
}
|
||||
[BodyNode::RawExpr(ref expr)] => {
|
||||
// TODO: let rawexprs to be inlined
|
||||
get_expr_length(expr)
|
||||
get_expr_length(&expr.expr)
|
||||
}
|
||||
[BodyNode::Element(ref el)] => {
|
||||
let attr_len = self.is_short_attrs(&el.attributes);
|
||||
@@ -301,8 +301,10 @@ impl Buffer {
|
||||
|
||||
if el.children.len() == 1 {
|
||||
if let BodyNode::Text(ref text) = el.children[0] {
|
||||
if text.value().len() + el.name.to_string().len() + attr_len < 80 {
|
||||
return Some(text.value().len() + el.name.to_string().len() + attr_len);
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,8 +318,8 @@ impl Buffer {
|
||||
for item in items {
|
||||
match item {
|
||||
BodyNode::Component(_) | BodyNode::Element(_) => return None,
|
||||
BodyNode::Text(text) => total_count += text.value().len(),
|
||||
BodyNode::RawExpr(expr) => match get_expr_length(expr) {
|
||||
BodyNode::Text(text) => total_count += text.text.value().len(),
|
||||
BodyNode::RawExpr(expr) => match get_expr_length(&expr.expr) {
|
||||
Some(len) => total_count += len,
|
||||
None => return None,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user