diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index c8395c3..aa03f3f 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -288,10 +288,8 @@ private: case conditional_newline: immutable l = currentLineLength + betweenParenLength(tokens[index + 1 .. $]); if (l > config.dfmt_soft_max_line_length) - { newline(); - } - else + else if (peekBackIs(tok!")")) write(" "); break; case always_newline: @@ -304,7 +302,7 @@ private: pushWrapIndent(tok!"!"); newline(); } - else + else if (peekBackIs(tok!")")) write(" "); break; case always_newline_indent: @@ -542,7 +540,7 @@ private: write(" "); } else if ((peekIsKeyword() || peekIs(tok!"@")) && spaceAfterParens - && !peekIs(tok!"in") && !peekIs(tok!"is")) + && !peekIs(tok!"in") && !peekIs(tok!"is") && !peekIs(tok!"if")) { writeToken(); write(" "); diff --git a/tests/allman/issue0153.d.ref b/tests/allman/issue0153.d.ref index 64b99c1..b5fb7e6 100644 --- a/tests/allman/issue0153.d.ref +++ b/tests/allman/issue0153.d.ref @@ -1,4 +1,5 @@ -class Foo(T) : FirstInterfaceWithVeryLongName, SecondInterfaceWithVeryLongName if (is(T : Bar)) +class Foo(T) : FirstInterfaceWithVeryLongName, SecondInterfaceWithVeryLongName + if (is(T : Bar)) { void foo() { diff --git a/tests/allman/issue0215a.d.ref b/tests/allman/issue0215a.d.ref index 91d51e9..fb82d3e 100644 --- a/tests/allman/issue0215a.d.ref +++ b/tests/allman/issue0215a.d.ref @@ -10,7 +10,7 @@ unittest bool anotherTemplatedFunction(One, Two, Three)(One alpha, Two bravo, Three charlie, double delta) if (isNumeric!One && isNumeric!Two && isNumeric!Three && echo - && foxtrot && golf && hotel && india && juliet) + && foxtrot && golf && hotel && india && juliet) { } diff --git a/tests/allman/issue0215d.d.ref b/tests/allman/issue0215d.d.ref index 747deff..501d7e7 100644 --- a/tests/allman/issue0215d.d.ref +++ b/tests/allman/issue0215d.d.ref @@ -11,7 +11,7 @@ unittest bool anotherTemplatedFunction(One, Two, Three)(One alpha, Two bravo, Three charlie, double delta) if (isNumeric!One && isNumeric!Two && isNumeric!Three && echo - && foxtrot && golf && hotel && india && juliet) + && foxtrot && golf && hotel && india && juliet) { } diff --git a/tests/otbs/issue0153.d.ref b/tests/otbs/issue0153.d.ref index f55efed..47cfcbc 100644 --- a/tests/otbs/issue0153.d.ref +++ b/tests/otbs/issue0153.d.ref @@ -1,4 +1,5 @@ -class Foo(T) : FirstInterfaceWithVeryLongName, SecondInterfaceWithVeryLongName if (is(T : Bar)) { +class Foo(T) : FirstInterfaceWithVeryLongName, SecondInterfaceWithVeryLongName + if (is(T : Bar)) { void foo() { } } diff --git a/tests/otbs/issue0215a.d.ref b/tests/otbs/issue0215a.d.ref index 8f62b4c..07dffc8 100644 --- a/tests/otbs/issue0215a.d.ref +++ b/tests/otbs/issue0215a.d.ref @@ -8,7 +8,7 @@ unittest { bool anotherTemplatedFunction(One, Two, Three)(One alpha, Two bravo, Three charlie, double delta) if (isNumeric!One && isNumeric!Two && isNumeric!Three && echo - && foxtrot && golf && hotel && india && juliet) { + && foxtrot && golf && hotel && india && juliet) { } } diff --git a/tests/otbs/issue0215d.d.ref b/tests/otbs/issue0215d.d.ref index 8624b69..625861f 100644 --- a/tests/otbs/issue0215d.d.ref +++ b/tests/otbs/issue0215d.d.ref @@ -9,7 +9,7 @@ unittest { bool anotherTemplatedFunction(One, Two, Three)(One alpha, Two bravo, Three charlie, double delta) if (isNumeric!One && isNumeric!Two && isNumeric!Three && echo - && foxtrot && golf && hotel && india && juliet) { + && foxtrot && golf && hotel && india && juliet) { } }