From 4fff6dc6352e0fecf5a12ae0e53eceda1f5b2cfb Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Wed, 13 May 2015 14:39:34 -0700 Subject: [PATCH] Fix #153 --- src/dfmt/formatter.d | 3 ++- tests/allman/issue0153.d.ref | 7 +++++++ tests/issue0153.d | 5 +++++ tests/otbs/issue0153.d.ref | 5 +++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/allman/issue0153.d.ref create mode 100644 tests/issue0153.d create mode 100644 tests/otbs/issue0153.d.ref diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 5318e59..3a26888 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -626,8 +626,9 @@ private: immutable bool a = !currentIs(tok!"version") && !currentIs(tok!"debug"); immutable bool b = a || astInformation.conditionalWithElseLocations.canFindIndex(current.index); - immutable bool shouldPushIndent = b + immutable bool c = b || astInformation.conditionalStatementLocations.canFindIndex(current.index); + immutable bool shouldPushIndent = c && !(currentIs(tok!"if") && indents.topIsWrap()); if (shouldPushIndent) indents.push(current.type); writeToken(); diff --git a/tests/allman/issue0153.d.ref b/tests/allman/issue0153.d.ref new file mode 100644 index 0000000..c9ac2df --- /dev/null +++ b/tests/allman/issue0153.d.ref @@ -0,0 +1,7 @@ +class Foo(T) : FirstInterfaceWithVeryLongName, + SecondInterfaceWithVeryLongName if (is(T : Bar)) +{ + void foo() + { + } +} diff --git a/tests/issue0153.d b/tests/issue0153.d new file mode 100644 index 0000000..bb6181d --- /dev/null +++ b/tests/issue0153.d @@ -0,0 +1,5 @@ +class Foo(T) : FirstInterfaceWithVeryLongName, + SecondInterfaceWithVeryLongName if (is(T : Bar)) { + void foo() { + } + } diff --git a/tests/otbs/issue0153.d.ref b/tests/otbs/issue0153.d.ref new file mode 100644 index 0000000..51e2cd2 --- /dev/null +++ b/tests/otbs/issue0153.d.ref @@ -0,0 +1,5 @@ +class Foo(T) : FirstInterfaceWithVeryLongName, + SecondInterfaceWithVeryLongName if (is(T : Bar)) { + void foo() { + } +}