Procházet zdrojové kódy

fix: adjust padding on autofmt

Jonathan Kelley před 2 roky
rodič
revize
3945928c59

+ 5 - 5
packages/autofmt/src/writer.rs

@@ -135,16 +135,16 @@ impl Writer<'_> {
 
             total += match &attr.attr {
                 ElementAttr::AttrText { value, name } => {
-                    value.source.as_ref().unwrap().value().len() + name.span().line_length() + 3
+                    value.source.as_ref().unwrap().value().len() + name.span().line_length() + 6
                 }
                 ElementAttr::AttrExpression { name, value } => {
-                    value.span().line_length() + name.span().line_length() + 3
+                    value.span().line_length() + name.span().line_length() + 6
                 }
                 ElementAttr::CustomAttrText { value, name } => {
-                    value.source.as_ref().unwrap().value().len() + name.value().len() + 3
+                    value.source.as_ref().unwrap().value().len() + name.value().len() + 6
                 }
                 ElementAttr::CustomAttrExpression { name, value } => {
-                    name.value().len() + value.span().line_length() + 3
+                    name.value().len() + value.span().line_length() + 6
                 }
                 ElementAttr::EventTokens { tokens, name } => {
                     let location = Location::new(tokens.span().start());
@@ -164,7 +164,7 @@ impl Writer<'_> {
                         self.cached_formats[&location].len()
                     };
 
-                    len + name.span().line_length() + 3
+                    len + name.span().line_length() + 6
                 }
             };
         }

+ 2 - 1
packages/autofmt/tests/samples.rs

@@ -36,5 +36,6 @@ twoway![
     messy_indent,
     long_exprs,
     ifchain_forloop,
-    t2
+    t2,
+    reallylong
 ];

+ 18 - 0
packages/autofmt/tests/samples/reallylong.rsx

@@ -0,0 +1,18 @@
+pub static Icon3: Component<()> = |cx| {
+    cx.render(rsx!(svg { class: "w-6 h-6",
+        stroke_linecap: "round",
+        fill: "none",
+        stroke_linejoin: "round",
+        stroke_width: "2",
+        stroke: "currentColor",
+        view_box: "0 0 24 24",
+        path {
+            d: "M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2",
+        }
+        circle {
+            cx: "12",
+            cy: "7",
+            r: "4",
+        }
+    }))
+};