Fix #108
This commit is contained in:
parent
efc9d72c95
commit
83072689d1
22
src/dfmt.d
22
src/dfmt.d
|
|
@ -223,7 +223,8 @@ private:
|
||||||
write(" ");
|
write(" ");
|
||||||
if (currentIs(tok!"("))
|
if (currentIs(tok!"("))
|
||||||
writeParens(false);
|
writeParens(false);
|
||||||
if (!currentIs(tok!"switch") && !currentIs(tok!"with") && !currentIs(tok!"{"))
|
if (!currentIs(tok!"switch") && !currentIs(tok!"with")
|
||||||
|
&& !currentIs(tok!"{") && !(currentIs(tok!"final") && peekIs(tok!"switch")))
|
||||||
{
|
{
|
||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
|
|
@ -457,15 +458,7 @@ private:
|
||||||
|
|
||||||
void formatColon()
|
void formatColon()
|
||||||
{
|
{
|
||||||
regenLineBreakHintsIfNecessary(index);
|
if (astInformation.caseEndLocations.canFindIndex(current.index)
|
||||||
if (linebreakHints.canFindIndex(index))
|
|
||||||
{
|
|
||||||
pushWrapIndent();
|
|
||||||
newline();
|
|
||||||
writeToken();
|
|
||||||
write(" ");
|
|
||||||
}
|
|
||||||
else if (astInformation.caseEndLocations.canFindIndex(current.index)
|
|
||||||
|| astInformation.attributeDeclarationLines.canFindIndex(current.line))
|
|| astInformation.attributeDeclarationLines.canFindIndex(current.line))
|
||||||
{
|
{
|
||||||
writeToken();
|
writeToken();
|
||||||
|
|
@ -482,6 +475,7 @@ private:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
regenLineBreakHintsIfNecessary(index);
|
||||||
if (peekIs(tok!".."))
|
if (peekIs(tok!".."))
|
||||||
writeToken();
|
writeToken();
|
||||||
else if (isBlockHeader(1) && !peekIs(tok!"if"))
|
else if (isBlockHeader(1) && !peekIs(tok!"if"))
|
||||||
|
|
@ -489,6 +483,13 @@ private:
|
||||||
writeToken();
|
writeToken();
|
||||||
write(" ");
|
write(" ");
|
||||||
}
|
}
|
||||||
|
else if (linebreakHints.canFindIndex(index))
|
||||||
|
{
|
||||||
|
pushWrapIndent();
|
||||||
|
newline();
|
||||||
|
writeToken();
|
||||||
|
write(" ");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write(" : ");
|
write(" : ");
|
||||||
|
|
@ -563,6 +564,7 @@ private:
|
||||||
}
|
}
|
||||||
writeToken();
|
writeToken();
|
||||||
newline();
|
newline();
|
||||||
|
linebreakHints = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
with (SomeEnum) final switch (value)
|
||||||
|
{
|
||||||
|
case a:
|
||||||
|
aa();
|
||||||
|
break;
|
||||||
|
case b:
|
||||||
|
bb();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
with (SomeEnum) final switch (value)
|
||||||
|
{
|
||||||
|
case a:
|
||||||
|
aa();
|
||||||
|
break;
|
||||||
|
case b:
|
||||||
|
bb();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
unittest {
|
||||||
|
with (SomeEnum) final switch (value) {
|
||||||
|
case a:
|
||||||
|
aa();
|
||||||
|
break;
|
||||||
|
case b:
|
||||||
|
bb();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue