This commit is contained in:
Hackerpilot 2016-01-20 17:00:46 -08:00
parent 3c6ea77a12
commit db2ad1354b
4 changed files with 20 additions and 5 deletions

View file

@ -209,8 +209,7 @@ private:
else if ((isBlockHeader() || currentIs(tok!"version") else if ((isBlockHeader() || currentIs(tok!"version")
|| currentIs(tok!"debug")) && peekIs(tok!"(", false)) || currentIs(tok!"debug")) && peekIs(tok!"(", false))
{ {
if (!assumeSorted(astInformation.constraintLocations) if (!assumeSorted(astInformation.constraintLocations).equalRange(current.index).empty)
.equalRange(current.index).empty)
formatConstrtaint(); formatConstrtaint();
else else
formatBlockHeader(); formatBlockHeader();
@ -365,7 +364,9 @@ private:
immutable canAddNewline = currTokenLine - prevTokenEndLine < 1; immutable canAddNewline = currTokenLine - prevTokenEndLine < 1;
if (peekBackIsOperator() && !isSeparationToken(t)) if (peekBackIsOperator() && !isSeparationToken(t))
pushWrapIndent(t); pushWrapIndent(t);
if (prevTokenEndLine == currTokenLine || (t == tok!")" && peekIs(tok!"{"))) if (peekBackIs(tok!")") && !canAddNewline && prevTokenEndLine < currTokenLine)
write(" ");
else if (prevTokenEndLine == currTokenLine || (t == tok!")" && peekIs(tok!"{")))
write(" "); write(" ");
else if (canAddNewline || (peekIs(tok!"{") && t == tok!"}")) else if (canAddNewline || (peekIs(tok!"{") && t == tok!"}"))
newline(); newline();
@ -1157,8 +1158,7 @@ private:
newline(); newline();
} }
else if (!peekIs(tok!"}") && (linebreakHints.canFind(index) else if (!peekIs(tok!"}") && (linebreakHints.canFind(index)
|| (linebreakHints.length == 0 || (linebreakHints.length == 0 && currentLineLength > config.max_line_length)))
&& currentLineLength > config.max_line_length)))
{ {
pushWrapIndent(); pushWrapIndent();
writeToken(); writeToken();

View file

@ -0,0 +1,5 @@
unittest
{
static if (stuff) // comment
things();
}

6
tests/issue0221.d Normal file
View file

@ -0,0 +1,6 @@
unittest
{
static if (stuff)
// comment
things();
}

View file

@ -0,0 +1,4 @@
unittest {
static if (stuff) // comment
things();
}