diff --git a/parser/printer.go b/parser/printer.go index 848b95a..c3ecf96 100644 --- a/parser/printer.go +++ b/parser/printer.go @@ -227,7 +227,7 @@ func (p *printer) printSelect(s *Select) { } else { p.printExpression(c.Value) } - p.printToken(",", c.Value.Pos()) + p.printToken(",", c.Value.End()) } p.requestNewline() p.unindent(s.RBracePos) diff --git a/parser/printer_test.go b/parser/printer_test.go index 3a81551..60568eb 100644 --- a/parser/printer_test.go +++ b/parser/printer_test.go @@ -696,6 +696,43 @@ foo { (default, default): "b", }), } +`, + }, + { + name: "Select with multiline inner expression", + input: ` +foo { + cflags: [ + "-DPRODUCT_COMPATIBLE_PROPERTY", + "-DRIL_SHLIB", + "-Wall", + "-Wextra", + "-Werror", + ] + select(soong_config_variable("sim", "sim_count"), { + "2": [ + "-DANDROID_MULTI_SIM", + "-DANDROID_SIM_COUNT_2", + ], + default: [], + }), +} +`, + output: ` +foo { + cflags: [ + "-DPRODUCT_COMPATIBLE_PROPERTY", + "-DRIL_SHLIB", + "-Wall", + "-Werror", + "-Wextra", + ] + select(soong_config_variable("sim", "sim_count"), { + "2": [ + "-DANDROID_MULTI_SIM", + "-DANDROID_SIM_COUNT_2", + ], + default: [], + }), +} `, }, }