Skip to content

Commit

Permalink
Allow Not to be in the same line if it is a single argument
Browse files Browse the repository at this point in the history
  • Loading branch information
crodas committed Dec 21, 2023
1 parent 4397e1c commit 96514e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions swayfmt/src/utils/language/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,10 @@ fn same_line_if_only_argument(expr: &Expr) -> bool {
Expr::Struct { path: _, fields: _ }
| Expr::Tuple(_)
| Expr::Parens(_)
| Expr::Not {
bang_token: _,
expr: _
}
| Expr::Path(_)
| Expr::FuncApp { func: _, args: _ }
| Expr::Match {
Expand Down
16 changes: 16 additions & 0 deletions swayfmt/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2671,3 +2671,19 @@ fn test() {
"#,
);
}

#[test]
fn single_argument_not() {
check(
r#"library;
fn test() {
assert(!(U256::from((0, 0, 0, 1)) > U256::from((0, u64::max(), 0, 0))));
}
"#,
r#"library;
fn test() {
assert(!(U256::from((0, 0, 0, 1)) > U256::from((0, u64::max(), 0, 0))));
}
"#,
);
}

0 comments on commit 96514e8

Please sign in to comment.