mirror of
https://github.com/dlang-community/dfmt.git
synced 2025-04-25 21:00:03 +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")
|
||||
|| currentIs(tok!"debug")) && peekIs(tok!"(", false))
|
||||
{
|
||||
if (!assumeSorted(astInformation.constraintLocations)
|
||||
.equalRange(current.index).empty)
|
||||
if (!assumeSorted(astInformation.constraintLocations).equalRange(current.index).empty)
|
||||
formatConstrtaint();
|
||||
else
|
||||
formatBlockHeader();
|
||||
|
@ -365,7 +364,9 @@ private:
|
|||
immutable canAddNewline = currTokenLine - prevTokenEndLine < 1;
|
||||
if (peekBackIsOperator() && !isSeparationToken(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(" ");
|
||||
else if (canAddNewline || (peekIs(tok!"{") && t == tok!"}"))
|
||||
newline();
|
||||
|
@ -1157,8 +1158,7 @@ private:
|
|||
newline();
|
||||
}
|
||||
else if (!peekIs(tok!"}") && (linebreakHints.canFind(index)
|
||||
|| (linebreakHints.length == 0
|
||||
&& currentLineLength > config.max_line_length)))
|
||||
|| (linebreakHints.length == 0 && currentLineLength > config.max_line_length)))
|
||||
{
|
||||
pushWrapIndent();
|
||||
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