diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 0225f4f7e7..aed47f1b96 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1718,7 +1718,7 @@ pub fn (mut f Fmt) call_args(args []ast.CallArg) { if arg.is_mut { f.write(arg.share.str() + ' ') } - if i > 0 { + if i > 0 && !f.single_line_if { f.wrap_long_line(3, true) } f.expr(arg.expr) @@ -1782,14 +1782,6 @@ pub fn (mut f Fmt) call_expr(node ast.CallExpr) { } f.expr(node.left) f.write('.' + node.name) - f.write_generic_if_require(node) - f.write('(') - f.call_args(node.args) - f.write(')') - // if is_mut { - // f.write('!') - // } - f.or_expr(node.or_block) } else { f.write_language_prefix(node.language) if node.left is ast.AnonFn { @@ -1804,12 +1796,12 @@ pub fn (mut f Fmt) call_expr(node ast.CallExpr) { } f.write('$name') } - f.write_generic_if_require(node) - f.write('(') - f.call_args(node.args) - f.write(')') - f.or_expr(node.or_block) } + f.write_generic_if_require(node) + f.write('(') + f.call_args(node.args) + f.write(')') + f.or_expr(node.or_block) f.comments(node.comments, has_nl: false) f.use_short_fn_args = old_short_arg_state } diff --git a/vlib/v/fmt/tests/if_ternary_expected.vv b/vlib/v/fmt/tests/if_ternary_expected.vv index 9578886e2e..e100a4aadf 100644 --- a/vlib/v/fmt/tests/if_ternary_expected.vv +++ b/vlib/v/fmt/tests/if_ternary_expected.vv @@ -31,3 +31,18 @@ fn condition_is_very_long_infix() { 'false' } } + +fn branches_are_long_fn_calls() { + _ := if nr_dims == 1 { + t.find_or_register_array(elem_type) + } else { + t.find_or_register_arra(t.find_or_register_array_with_dims(elem_type, nr_dims - 1)) + } + // With another arg to make fn call exceed the max_len after if unwrapping + _ := if nr_dims == 1 { + t.find_or_register_array(elem_type) + } else { + t.find_or_register_arra(t.find_or_register_array_with_dims(elem_type, nr_dims - 1, + 'some string')) + } +} diff --git a/vlib/v/fmt/tests/if_ternary_input.vv b/vlib/v/fmt/tests/if_ternary_input.vv index badcd76dad..c76a8ffdc5 100644 --- a/vlib/v/fmt/tests/if_ternary_input.vv +++ b/vlib/v/fmt/tests/if_ternary_input.vv @@ -11,3 +11,9 @@ fn main() { fn condition_is_very_long_infix() { val := if the_first_condition && this_is_required_too && (another_cond || foobar_to_exceed_the_max_len) { 'true' } else { 'false' } } + +fn branches_are_long_fn_calls() { + _ := if nr_dims == 1 { t.find_or_register_array(elem_type) } else { t.find_or_register_arra(t.find_or_register_array_with_dims(elem_type, nr_dims - 1)) } + // With another arg to make fn call exceed the max_len after if unwrapping + _ := if nr_dims == 1 { t.find_or_register_array(elem_type) } else { t.find_or_register_arra(t.find_or_register_array_with_dims(elem_type, nr_dims - 1, 'some string')) } +} diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index f25451194b..e673895208 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -228,8 +228,11 @@ pub fn (ctx &Context) get_cookie(key string) ?string { // TODO refactor cookie_header = ' ' + cookie_header // println('cookie_header="$cookie_header"') // println(ctx.req.headers) - cookie := if cookie_header.contains(';') { cookie_header.find_between(' $key=', ';') } else { cookie_header.find_between(' $key=', - '\r') } + cookie := if cookie_header.contains(';') { + cookie_header.find_between(' $key=', ';') + } else { + cookie_header.find_between(' $key=', '\r') + } if cookie != '' { return cookie.trim_space() }