diff --git a/core/formatter.cpp b/core/formatter.cpp index 064d77e29..15748627c 100644 --- a/core/formatter.cpp +++ b/core/formatter.cpp @@ -97,7 +97,8 @@ void fodder_fill(std::ostream &o, const Fodder &fodder, bool space_before, bool } /** A model of fodder_fill that just keeps track of the column counter. */ -static void fodder_count(unsigned &column, const Fodder &fodder, bool space_before, bool separate_token) +static void fodder_count(unsigned &column, const Fodder &fodder, bool space_before, + bool separate_token) { for (const auto &fod : fodder) { switch (fod.kind) { @@ -1140,10 +1141,10 @@ class FixTrailingCommas : public Pass { if (!need_comma) { // Remove it but keep fodder. trailing_comma = false; - fodder_move_back(close_fodder, last_comma_fodder); + fodder_move_front(close_fodder, last_comma_fodder); } else if (contains_newline(last_comma_fodder)) { // The comma is needed but currently is separated by a newline. - fodder_move_back(close_fodder, last_comma_fodder); + fodder_move_front(close_fodder, last_comma_fodder); } } else { if (need_comma) { diff --git a/test_suite/formatter.jsonnet b/test_suite/formatter.jsonnet index 29b28b446..38ffd9754 100644 --- a/test_suite/formatter.jsonnet +++ b/test_suite/formatter.jsonnet @@ -36,6 +36,12 @@ limitations under the License. g: 2, }, + local test_local5 = { + x: + true + , + }, + local test_local_default1(x=100, y=200) = { g: 2, }, diff --git a/test_suite/formatter.jsonnet.fmt.golden b/test_suite/formatter.jsonnet.fmt.golden index cc49a84c1..a0c15d5dc 100644 --- a/test_suite/formatter.jsonnet.fmt.golden +++ b/test_suite/formatter.jsonnet.fmt.golden @@ -36,6 +36,11 @@ limitations under the License. g: 2, }, + local test_local5 = { + x: + true, + }, + local test_local_default1(x=100, y=200) = { g: 2, },