diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 24202f455b..d660f88afc 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -179,10 +179,18 @@ fn (f mut Fmt) stmt(node ast.Stmt) { f.write('pub ') } f.writeln('const (') + mut max := 0 + for field in it.fields { + if field.name.len > max { + max = field.name.len + } + } f.indent++ for i, field in it.fields { name := field.name.after('.') - f.write('$name = ') + f.write('$name ') + f.write(strings.repeat(` `, max - field.name.len)) + f.write('= ') f.expr(field.expr) f.writeln('') } diff --git a/vlib/v/fmt/tests/consts_expected.vv b/vlib/v/fmt/tests/consts_expected.vv index f81be5f631..0da7ad1870 100644 --- a/vlib/v/fmt/tests/consts_expected.vv +++ b/vlib/v/fmt/tests/consts_expected.vv @@ -1,5 +1,7 @@ const ( - pi = 3.14 + pi = 3.14 + phi = 1.618 + eulers = 2.7182 ) pub const ( diff --git a/vlib/v/fmt/tests/consts_input.vv b/vlib/v/fmt/tests/consts_input.vv index 2b7c5c874c..67d06dcaa1 100644 --- a/vlib/v/fmt/tests/consts_input.vv +++ b/vlib/v/fmt/tests/consts_input.vv @@ -1,5 +1,7 @@ const ( pi=3.14 +phi=1.618 +eulers=2.7182 ) pub const (