diff --git a/packages/autofmt/src/lib.rs b/packages/autofmt/src/lib.rs index 4c3386e36..1eab6240f 100644 --- a/packages/autofmt/src/lib.rs +++ b/packages/autofmt/src/lib.rs @@ -47,7 +47,7 @@ pub fn fmt_file(contents: &str) -> Vec { continue; } - let indent_level = { + let mut indent_level = { // walk backwards from start until we find a new line let mut lines = contents[..start].lines().rev(); match lines.next() { @@ -71,6 +71,10 @@ pub fn fmt_file(contents: &str) -> Vec { if new.len() <= 80 && !new.contains('\n') { new = format!(" {new} "); + + // if the new string is not multiline, don't try to adjust the marker ending + // We want to trim off any indentation that there might be + indent_level = 0; } let end_marker = end + bracket_end - indent_level * 4 - 1; diff --git a/packages/autofmt/tests/wrong.rs b/packages/autofmt/tests/wrong.rs index f15849573..4666da79c 100644 --- a/packages/autofmt/tests/wrong.rs +++ b/packages/autofmt/tests/wrong.rs @@ -12,3 +12,5 @@ macro_rules! twoway { } twoway!("comments" => comments); + +twoway!("multi" => multi); diff --git a/packages/autofmt/tests/wrong/multi.rsx b/packages/autofmt/tests/wrong/multi.rsx new file mode 100644 index 000000000..d43b9a1e9 --- /dev/null +++ b/packages/autofmt/tests/wrong/multi.rsx @@ -0,0 +1,3 @@ +fn app(cx: Scope) -> Element { + cx.render(rsx! { div { "hello world" } }) +} diff --git a/packages/autofmt/tests/wrong/multi.wrong.rsx b/packages/autofmt/tests/wrong/multi.wrong.rsx new file mode 100644 index 000000000..ccb6cab03 --- /dev/null +++ b/packages/autofmt/tests/wrong/multi.wrong.rsx @@ -0,0 +1,5 @@ +fn app(cx: Scope) -> Element { + cx.render(rsx! { + div {"hello world" } + }) +} diff --git a/packages/router/examples/simple.rs b/packages/router/examples/simple.rs index c8aba6a20..1b706970e 100644 --- a/packages/router/examples/simple.rs +++ b/packages/router/examples/simple.rs @@ -11,14 +11,14 @@ fn main() { fn app(cx: Scope) -> Element { cx.render(rsx! { - Router { + Router { h1 { "Your app here" } ul { - Link { to: "/", li { "home" }} - Link { to: "/blog", li { "blog" }} - Link { to: "/blog/tim", li { "tims' blog" }} - Link { to: "/blog/bill", li { "bills' blog" }} - Link { to: "/apples", li { "go to apples" }} + Link { to: "/", li { "home" } } + Link { to: "/blog", li { "blog" } } + Link { to: "/blog/tim", li { "tims' blog" } } + Link { to: "/blog/bill", li { "bills' blog" } } + Link { to: "/apples", li { "go to apples" } } } Route { to: "/", Home {} } Route { to: "/blog/", BlogList {} } @@ -30,15 +30,11 @@ fn app(cx: Scope) -> Element { } fn Home(cx: Scope) -> Element { - cx.render(rsx! { - h1 { "Home" } - }) + cx.render(rsx! { h1 { "Home" } }) } fn BlogList(cx: Scope) -> Element { - cx.render(rsx! { - div { "Blog List" } - }) + cx.render(rsx! { div { "Blog List" } }) } fn BlogPost(cx: Scope) -> Element {