From 22e17c3e8fa5427cac46f66cbf82b69fdf7567e1 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:32:36 +0100 Subject: [PATCH] fmt: remove additional line breaks after call_expr before params struct args (#19795) --- vlib/v/fmt/fmt.v | 5 +++-- ..._call_with_call_expr_and_params_struct_args_keep.vv | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 vlib/v/fmt/tests/fn_call_with_call_expr_and_params_struct_args_keep.vv diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 4618fe6cb2..8a562269ab 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1976,11 +1976,12 @@ fn (mut f Fmt) write_generic_call_if_require(node ast.CallExpr) { } pub fn (mut f Fmt) call_args(args []ast.CallArg) { - f.single_line_fields = true + old_single_line_fields_state := f.single_line_fields old_short_arg_state := f.use_short_fn_args + f.single_line_fields = true f.use_short_fn_args = false defer { - f.single_line_fields = false + f.single_line_fields = old_single_line_fields_state f.use_short_fn_args = old_short_arg_state } for i, arg in args { diff --git a/vlib/v/fmt/tests/fn_call_with_call_expr_and_params_struct_args_keep.vv b/vlib/v/fmt/tests/fn_call_with_call_expr_and_params_struct_args_keep.vv new file mode 100644 index 0000000000..6cfd3cd099 --- /dev/null +++ b/vlib/v/fmt/tests/fn_call_with_call_expr_and_params_struct_args_keep.vv @@ -0,0 +1,10 @@ +[params] +struct Bar { + bar bool +} + +fn foo(msg string, opts Bar) { + println(msg) +} + +foo(123.str(), bar: true)