diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index ca8641f..16eb6ed 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -713,13 +713,13 @@ private: { writeToken(); if (spaceAfterParens || parenDepth > 0) - write(" "); + writeSpace(); } else if ((peekIsKeyword() || peekIs(tok!"@")) && spaceAfterParens && !peekIs(tok!"in") && !peekIs(tok!"is") && !peekIs(tok!"if")) { writeToken(); - write(" "); + writeSpace(); } else writeToken(); @@ -769,14 +769,7 @@ private: || currentIs(tok!"identifier")) && !currentIsIndentedTemplateConstraint()) { - if (onNextLine) - { - newline(); - } - else - { - write(" "); - } + writeSpace(); } } @@ -1289,14 +1282,7 @@ private: default: if (peekBackIs(tok!"identifier")) { - if (onNextLine) - { - newline(); - } - else - { - write(" "); - } + writeSpace(); } if (index + 1 < tokens.length) { @@ -1310,14 +1296,7 @@ private: writeToken(); if (!currentIsIndentedTemplateConstraint()) { - if (onNextLine) - { - newline(); - } - else - { - write(" "); - } + writeSpace(); } } } @@ -1943,6 +1922,18 @@ private: indents.push(type, detail); } + void writeSpace() + { + if (onNextLine) + { + newline(); + } + else + { + write(" "); + } + } + const pure @safe @nogc: size_t expressionEndIndex(size_t i, bool matchComma = false) nothrow diff --git a/tests/allman/issue0504.d.ref b/tests/allman/issue0504.d.ref new file mode 100644 index 0000000..7fb4598 --- /dev/null +++ b/tests/allman/issue0504.d.ref @@ -0,0 +1,40 @@ +deprecated("foo") +void test() +{ +} + +package(foo) +void bar() +{ +} + +@uda() +void baz() +{ +} + +deprecated +deprecated_() +{ +} + +@uda +void uda_() +{ +} + +@property +void property() +{ +} + +deprecated("Reason") @uda +void propertyuda() +{ +} + +deprecated("Reason") +@uda +void udaproperty() +{ +} diff --git a/tests/issue0504.args b/tests/issue0504.args new file mode 100644 index 0000000..7e7e52d --- /dev/null +++ b/tests/issue0504.args @@ -0,0 +1 @@ +--keep_line_breaks=true diff --git a/tests/issue0504.d b/tests/issue0504.d new file mode 100644 index 0000000..7fb4598 --- /dev/null +++ b/tests/issue0504.d @@ -0,0 +1,40 @@ +deprecated("foo") +void test() +{ +} + +package(foo) +void bar() +{ +} + +@uda() +void baz() +{ +} + +deprecated +deprecated_() +{ +} + +@uda +void uda_() +{ +} + +@property +void property() +{ +} + +deprecated("Reason") @uda +void propertyuda() +{ +} + +deprecated("Reason") +@uda +void udaproperty() +{ +} diff --git a/tests/otbs/issue0504.d.ref b/tests/otbs/issue0504.d.ref new file mode 100644 index 0000000..94a222c --- /dev/null +++ b/tests/otbs/issue0504.d.ref @@ -0,0 +1,32 @@ +deprecated("foo") +void test() { +} + +package(foo) +void bar() { +} + +@uda() +void baz() { +} + +deprecated +deprecated_() { +} + +@uda +void uda_() { +} + +@property +void property() { +} + +deprecated("Reason") @uda +void propertyuda() { +} + +deprecated("Reason") +@uda +void udaproperty() { +}