diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 37e0715f6e..d87df10417 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1734,7 +1734,7 @@ pub fn (mut f Fmt) if_expr(node ast.IfExpr) { f.single_line_if = false if node.post_comments.len > 0 { f.writeln('') - f.comments(node.post_comments, + f.comments(node.post_comments, has_nl: false prev_line: node.branches.last().body_pos.last_line ) @@ -2176,6 +2176,14 @@ pub fn (mut f Fmt) struct_init(node ast.StructInit) { fields_start := f.out.len fields_loop: for { if !single_line_fields { + if use_short_args && f.out.buf[f.out.buf.len - 1] == ` ` { + // v Remove space at tail of line + // f(a, b, c, \n + // f1: 0\n + // f2: 1\n + // ) + f.out.go_back(1) + } f.writeln('') f.indent++ } diff --git a/vlib/v/fmt/tests/fn_trailing_arg_syntax_expected.vv b/vlib/v/fmt/tests/fn_trailing_arg_syntax_expected.vv index 4e649cd9c1..1f1cd4a7ce 100644 --- a/vlib/v/fmt/tests/fn_trailing_arg_syntax_expected.vv +++ b/vlib/v/fmt/tests/fn_trailing_arg_syntax_expected.vv @@ -6,6 +6,7 @@ struct Bar { struct Baz { x int + y int } fn main() { @@ -18,8 +19,13 @@ fn main() { x: 'some string' b: Baz{ x: 0 + y: 0 } ) + baz_func('foo', 'bar', + x: 0 + y: 0 + ) ui.row( // stretch: true margin: { @@ -33,3 +39,5 @@ fn main() { fn bar_func(bar Bar) { } + +fn baz_func(a string, b string, baz Baz) {} diff --git a/vlib/v/fmt/tests/fn_trailing_arg_syntax_input.vv b/vlib/v/fmt/tests/fn_trailing_arg_syntax_input.vv index 84ab9cd728..5ea1f6465e 100644 --- a/vlib/v/fmt/tests/fn_trailing_arg_syntax_input.vv +++ b/vlib/v/fmt/tests/fn_trailing_arg_syntax_input.vv @@ -6,6 +6,7 @@ struct Bar { struct Baz { x int + y int } fn main() { @@ -13,7 +14,11 @@ fn main() { bar_func(x: 'a very long content should cause vfmt to use multiple lines instead of one.', y: 123456789) bar_func(x: 'some string', b: Baz{ x: 0 + y: 0 }) + baz_func('foo', 'bar', x: 0 + y: 0 + ) ui.row({ //stretch: true margin: {top:10,left:10,right:10,bottom:10} @@ -22,3 +27,5 @@ fn main() { fn bar_func(bar Bar) { } + +fn baz_func(a string, b string, baz Baz) {} diff --git a/vlib/vweb/tests/vweb_test.v b/vlib/vweb/tests/vweb_test.v index a1f9259236..a6b21b6a89 100644 --- a/vlib/vweb/tests/vweb_test.v +++ b/vlib/vweb/tests/vweb_test.v @@ -220,7 +220,7 @@ fn test_http_client_shutdown_does_not_work_without_a_cookie() { fn testsuite_end() { // This test is guaranteed to be called last. // It sends a request to the server to shutdown. - x := http.fetch('http://127.0.0.1:$sport/shutdown', + x := http.fetch('http://127.0.0.1:$sport/shutdown', method: .get cookies: map{ 'skey': 'superman'