From 079a3666dd7a124dd6ab599250adb1a7a0dd2f6c Mon Sep 17 00:00:00 2001 From: kek kek kek Date: Sat, 28 Oct 2023 17:07:26 +0000 Subject: [PATCH] chore: Modify single line if-else expression width threshold --- tooling/nargo_fmt/src/config.rs | 2 +- tooling/nargo_fmt/tests/expected/if.nr | 12 ++++++++++++ tooling/nargo_fmt/tests/input/if.nr | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tooling/nargo_fmt/src/config.rs b/tooling/nargo_fmt/src/config.rs index dd57778da92..b81fc47cf09 100644 --- a/tooling/nargo_fmt/src/config.rs +++ b/tooling/nargo_fmt/src/config.rs @@ -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 { diff --git a/tooling/nargo_fmt/tests/expected/if.nr b/tooling/nargo_fmt/tests/expected/if.nr index 9893239750c..30a60e50577 100644 --- a/tooling/nargo_fmt/tests/expected/if.nr +++ b/tooling/nargo_fmt/tests/expected/if.nr @@ -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 { (); (); diff --git a/tooling/nargo_fmt/tests/input/if.nr b/tooling/nargo_fmt/tests/input/if.nr index 0985928396d..ab39df006ea 100644 --- a/tooling/nargo_fmt/tests/input/if.nr +++ b/tooling/nargo_fmt/tests/input/if.nr @@ -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 { ();