From 56ea97efbbabbbace7b4c7e4173d58f5ce6a07b6 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Thu, 7 May 2015 23:51:15 -0700 Subject: [PATCH] Fix #151 --- src/dfmt/formatter.d | 8 +++++++- tests/allman/issue0151.d.ref | 7 +++++++ tests/issue0151.d | 7 +++++++ tests/otbs/issue0151.d.ref | 5 +++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/allman/issue0151.d.ref create mode 100644 tests/issue0151.d create mode 100644 tests/otbs/issue0151.d.ref diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 9d740aa..b9d320a 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -261,7 +261,13 @@ private: { if (index < tokens.length && prevTokenEndLine == tokens[index].line) { - if (!currentIs(tok!"{")) + if (currentIs(tok!"}")) + { + if (indents.topIs(tok!"{")) + indents.pop(); + write(" "); + } + else if (!currentIs(tok!"{")) write(" "); } else if (!currentIs(tok!"{")) diff --git a/tests/allman/issue0151.d.ref b/tests/allman/issue0151.d.ref new file mode 100644 index 0000000..639e6bb --- /dev/null +++ b/tests/allman/issue0151.d.ref @@ -0,0 +1,7 @@ +void test() +{ /* ignore */ } + +void test2() +{ + test(); +} diff --git a/tests/issue0151.d b/tests/issue0151.d new file mode 100644 index 0000000..9b48a3b --- /dev/null +++ b/tests/issue0151.d @@ -0,0 +1,7 @@ +void test() +{ /* ignore */ } + + void test2() + { + test(); + } diff --git a/tests/otbs/issue0151.d.ref b/tests/otbs/issue0151.d.ref new file mode 100644 index 0000000..ac9e1a6 --- /dev/null +++ b/tests/otbs/issue0151.d.ref @@ -0,0 +1,5 @@ +void test() { /* ignore */ } + +void test2() { + test(); +}