Skip to content

Commit

Permalink
feat: preserve formatting of unknown macros
Browse files Browse the repository at this point in the history
  • Loading branch information
bram209 committed May 24, 2024
1 parent d96ff25 commit baf85a2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
fetch-depth: 0

- name: Generate a changelog
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions formatter/src/source_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,61 @@ mod tests {
"#);
}

#[test]
fn preserve_formatting_unknown_macros() {
let source = indoc! {r#"
#[component]
pub fn HeaderField() -> impl IntoView {
view! {
<div class="HeaderField start">
<h1>Hello Kanna</h1>
</div>
{
style! {
h1 {
background-color: red;
color: white;
}
@media (orientation: portrait) {
h1 {
background-color: green;
}
}
}
}
}
}"#};

let result = format_file_source(source, &Default::default()).unwrap();
insta::assert_snapshot!(result, @r###"
#[component]
pub fn HeaderField() -> impl IntoView {
view! {
<div class="HeaderField start">
<h1>Hello Kanna</h1>
</div>
{
style! {
h1 {
background-color: red;
color: white;
}
@media (orientation: portrait) {
h1 {
background-color: green;
}
}
}
}
}
}
"###);
}

#[test]
fn fully_qualified_macro_path_overridden() {
let source = indoc! {r#"
Expand Down
2 changes: 1 addition & 1 deletion prettyplease
Submodule prettyplease updated 2 files
+1 −1 Cargo.toml
+8 −2 src/mac.rs
2 changes: 1 addition & 1 deletion printer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "leptosfmt-pretty-printer"
version = "0.1.8"
version = { workspace = true }
edition = "2021"
description = "leptosfmt's pretty printer based on the prettyplease crate"
license = { workspace = true }
Expand Down

0 comments on commit baf85a2

Please sign in to comment.