From 3af8edc57f989aed1234666bd366e62229af4115 Mon Sep 17 00:00:00 2001 From: Kotet Date: Mon, 13 May 2019 19:06:59 +0900 Subject: [PATCH] Fix #361 - Unexpected empty new line if function header ends with a comment --- src/dfmt/formatter.d | 2 +- tests/allman/issue0361.d.ref | 15 +++++++++++++++ tests/issue0361.d | 15 +++++++++++++++ tests/otbs/issue0361.d.ref | 11 +++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/allman/issue0361.d.ref create mode 100644 tests/issue0361.d create mode 100644 tests/otbs/issue0361.d.ref diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 753a0f3..ee36f40 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -473,7 +473,7 @@ private: else if (!currentIs(tok!"{")) write(" "); } - else if (!currentIs(tok!"{")) + else if (!currentIs(tok!"{") && !currentIs(tok!"in") && !currentIs(tok!"out")) { if (currentIs(tok!")") && indents.topIs(tok!",")) indents.pop(); diff --git a/tests/allman/issue0361.d.ref b/tests/allman/issue0361.d.ref new file mode 100644 index 0000000..30c7f2e --- /dev/null +++ b/tests/allman/issue0361.d.ref @@ -0,0 +1,15 @@ +void foo() /**/ +in +{ +} +body +{ +} + +void bar() /**/ +out +{ +} +body +{ +} diff --git a/tests/issue0361.d b/tests/issue0361.d new file mode 100644 index 0000000..30c7f2e --- /dev/null +++ b/tests/issue0361.d @@ -0,0 +1,15 @@ +void foo() /**/ +in +{ +} +body +{ +} + +void bar() /**/ +out +{ +} +body +{ +} diff --git a/tests/otbs/issue0361.d.ref b/tests/otbs/issue0361.d.ref new file mode 100644 index 0000000..7e2b562 --- /dev/null +++ b/tests/otbs/issue0361.d.ref @@ -0,0 +1,11 @@ +void foo() /**/ +in { +} +body { +} + +void bar() /**/ +out { +} +body { +}