mirror of
https://github.com/RGBCube/alejandra
synced 2025-08-01 13:07:47 +00:00
Merge pull request #146 from kamadorueda/kamadorueda
feat: do not indent lambdas with comments
This commit is contained in:
commit
408830d42d
4 changed files with 35 additions and 1 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -78,6 +78,18 @@ Types of changes
|
||||||
- with pkgs;
|
- with pkgs;
|
||||||
+ binPath = with pkgs;
|
+ binPath = with pkgs;
|
||||||
```
|
```
|
||||||
|
- Nested lambdas are now not indented:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
# comment
|
||||||
|
a:
|
||||||
|
- # comment
|
||||||
|
- b:
|
||||||
|
- _
|
||||||
|
+ # comment
|
||||||
|
+ b:
|
||||||
|
+ _
|
||||||
|
```
|
||||||
|
|
||||||
## [0.2.0] - 2022-02-17
|
## [0.2.0] - 2022-02-17
|
||||||
|
|
||||||
|
|
|
@ -79,10 +79,11 @@ pub fn rule(
|
||||||
child.element.kind(),
|
child.element.kind(),
|
||||||
rnix::SyntaxKind::NODE_ATTR_SET
|
rnix::SyntaxKind::NODE_ATTR_SET
|
||||||
| rnix::SyntaxKind::NODE_PAREN
|
| rnix::SyntaxKind::NODE_PAREN
|
||||||
|
| rnix::SyntaxKind::NODE_LAMBDA
|
||||||
| rnix::SyntaxKind::NODE_LET_IN
|
| rnix::SyntaxKind::NODE_LET_IN
|
||||||
| rnix::SyntaxKind::NODE_LIST
|
| rnix::SyntaxKind::NODE_LIST
|
||||||
| rnix::SyntaxKind::NODE_STRING
|
| rnix::SyntaxKind::NODE_STRING
|
||||||
) && build_ctx.pos_new.column > 1;
|
);
|
||||||
|
|
||||||
if should_indent {
|
if should_indent {
|
||||||
steps.push_back(crate::builder::Step::Indent);
|
steps.push_back(crate::builder::Step::Indent);
|
||||||
|
|
9
tests/cases/idioms_lib_1/in
Normal file
9
tests/cases/idioms_lib_1/in
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
traceIf =
|
||||||
|
# Predicate to check
|
||||||
|
pred:
|
||||||
|
# Message that should be traced
|
||||||
|
msg:
|
||||||
|
# Value to return
|
||||||
|
x: if pred then trace msg x else x;
|
||||||
|
}
|
12
tests/cases/idioms_lib_1/out
Normal file
12
tests/cases/idioms_lib_1/out
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
traceIf =
|
||||||
|
# Predicate to check
|
||||||
|
pred:
|
||||||
|
# Message that should be traced
|
||||||
|
msg:
|
||||||
|
# Value to return
|
||||||
|
x:
|
||||||
|
if pred
|
||||||
|
then trace msg x
|
||||||
|
else x;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue