mirror of
https://github.com/dlang-community/dfmt.git
synced 2025-04-29 22:59:57 +03:00
Fix #221
This commit is contained in:
parent
3c6ea77a12
commit
db2ad1354b
4 changed files with 20 additions and 5 deletions
|
@ -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();
|
||||||
|
|
5
tests/allman/issue0221.d.ref
Normal file
5
tests/allman/issue0221.d.ref
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
static if (stuff) // comment
|
||||||
|
things();
|
||||||
|
}
|
6
tests/issue0221.d
Normal file
6
tests/issue0221.d
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
static if (stuff)
|
||||||
|
// comment
|
||||||
|
things();
|
||||||
|
}
|
4
tests/otbs/issue0221.d.ref
Normal file
4
tests/otbs/issue0221.d.ref
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
unittest {
|
||||||
|
static if (stuff) // comment
|
||||||
|
things();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue