diff --git a/README.md b/README.md index c9b9fca..bd8098d 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ Let's get Alejandra on our systems: and formats [Nixpkgs](https://github.com/NixOS/nixpkgs) in under 1 minute. + That's 55000 lines of Nix code per second. + - ✔️ **Highly tested** Coverage currently > 80%, @@ -75,6 +77,11 @@ Let's get Alejandra on our systems: All elements in the Nix grammar have a rule, so there won't be portions of code unformatted. +- ✔️ **Tolerant to syntax errors** + + We'll format the portions of a file that is valid Nix code, + and leave as-is the portions that contain syntax errors. + - ✔️ **Reproducible** Formatting many times yields the same results. @@ -84,8 +91,8 @@ Let's get Alejandra on our systems: Beauty is subjective, right? Yet there are a few improvements to implement like: - - Multiline strings indentation `'' ... ''`. - - Multiline comments indentation `/* ... */`. + - Multiline strings indentation is missing `'' ... ''`. + - Multiline comments indentation is bugged `/* ... */`. - And many more as community feedback drives. Style is negotiable at this moment. diff --git a/src/rules/pat_entry.rs b/src/rules/pat_entry.rs index 7be2366..ee30f6f 100644 --- a/src/rules/pat_entry.rs +++ b/src/rules/pat_entry.rs @@ -16,17 +16,7 @@ pub fn rule( let child = children.get_next().unwrap(); match layout { crate::config::Layout::Tall => { - match child.element.kind() { - rnix::SyntaxKind::NODE_OR_DEFAULT => { - steps - .push_back(crate::builder::Step::Format(child.element)); - } - _ => { - steps.push_back(crate::builder::Step::FormatWider( - child.element, - )); - } - } + steps.push_back(crate::builder::Step::FormatWider(child.element)); steps.push_back(crate::builder::Step::Indent); } crate::config::Layout::Wide => { diff --git a/tests/cases/pattern/in b/tests/cases/pattern/in index ca248aa..439788f 100644 --- a/tests/cases/pattern/in +++ b/tests/cases/pattern/in @@ -70,4 +70,7 @@ ({ /*a*/ b /*c*/ , /*d*/ e /*f*/ , ... /*h*/ }: _) ({ /*a*/ b /*c*/ , /*d*/ e /*f*/ , /*g*/ ... }: _) ({ /*a*/ b /*c*/ , /*d*/ e /*f*/ , /*g*/ ... /*h*/ }: _) + + ({ a ? null }: _) + ({ /*a*/ b /*a*/ ? /*a*/ null /*c*/ , /*d*/ e /*a*/ ? /*a*/ null /*f*/ , /*g*/ ... /*h*/ }: _) ] diff --git a/tests/cases/pattern/out b/tests/cases/pattern/out index 99573fb..ad95b97 100644 --- a/tests/cases/pattern/out +++ b/tests/cases/pattern/out @@ -659,4 +659,26 @@ }: _ ) + ( { a ? null }: _ ) + ( + { /*a*/ + b + /*a*/ + ? + /*a*/ + null + /*c*/ + , /*d*/ + e + /*a*/ + ? + /*a*/ + null + /*f*/ + , /*g*/ + ... + /*h*/ + }: + _ + ) ]