Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fmt closing brace #231

Merged
merged 2 commits into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions test_suite/formatter.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
5 changes: 5 additions & 0 deletions test_suite/formatter.jsonnet.fmt.golden
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down