wip: rely on git version of prettyplease, refactor autofmt

This commit is contained in:
Jonathan Kelley committed 2022-06-25 00:55:52 -04:00
1 parent 5b9e34aadd
commit 398cbc6534
31 files changed
+466 -4812

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
use dioxus_rsx::*;
use std::fmt::Write;
pub fn extract_attr_len(attributes: &[ElementAttrNamed]) -> usize {
attributes
.iter()
.map(|attr| match &attr.attr {
ElementAttr::AttrText { name, value } => value.value().len(),
ElementAttr::AttrExpression { name, value } => 10,
ElementAttr::CustomAttrText { name, value } => value.value().len(),
ElementAttr::CustomAttrExpression { name, value } => 10,
ElementAttr::EventTokens { name, tokens } => 1000000,
})
.sum::<usize>()
}
pub fn write_tabs(f: &mut dyn Write, num: usize) -> std::fmt::Result {
for _ in 0..num {
write!(f, " ")?
}
Ok(())
}
pub fn find_bracket_end(contents: &str) -> Option<usize> {
let mut depth = 0;
let mut i = 0;
for c in contents.chars() {
if c == '{' {
depth += 1;
} else if c == '}' {
depth -= 1;
}
if depth == 0 {
return Some(i);
}
i += 1;
}
None
}