Skip to content

Commit

Permalink
chore: Modify single line if-else expression width threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
kek kek kek committed Oct 28, 2023
1 parent dbb6cf0 commit 079a366
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tooling/nargo_fmt/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ config! {
remove_nested_parens: bool, true, "Remove nested parens";
short_array_element_width_threshold: usize, 10, "Width threshold for an array element to be considered short";
array_width: usize, 100, "Maximum width of an array literal before falling back to vertical formatting";
single_line_if_else_max_width: usize, 100, "Maximum line length for single line if-else expressions";
single_line_if_else_max_width: usize, 50, "Maximum line length for single line if-else expressions";
}

impl Config {
Expand Down
12 changes: 12 additions & 0 deletions tooling/nargo_fmt/tests/expected/if.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
fn main() {
let (x,y) = if is_square(gx1) {
(x1, sqrt(gx1))
} else {
(x2, sqrt(gx2))
};

let n = if x != y {
if x != 20 { slice.push_back(y) } else { slice }
} else {
slice
};

if false {
();
();
Expand Down
4 changes: 4 additions & 0 deletions tooling/nargo_fmt/tests/input/if.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
fn main() {
let (x,y) = if is_square(gx1) {(x1, sqrt(gx1))} else {(x2, sqrt(gx2))};

let n = if x != y { if x != 20 { slice.push_back(y) } else { slice } } else { slice };

if false
{
();
Expand Down

0 comments on commit 079a366

Please sign in to comment.