This commit is contained in:
Hackerpilot 2015-03-16 15:59:35 -07:00
parent efc9d72c95
commit 83072689d1
4 changed files with 46 additions and 10 deletions

View file

@ -223,7 +223,8 @@ private:
write(" ");
if (currentIs(tok!"("))
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();
}
@ -457,15 +458,7 @@ private:
void formatColon()
{
regenLineBreakHintsIfNecessary(index);
if (linebreakHints.canFindIndex(index))
{
pushWrapIndent();
newline();
writeToken();
write(" ");
}
else if (astInformation.caseEndLocations.canFindIndex(current.index)
if (astInformation.caseEndLocations.canFindIndex(current.index)
|| astInformation.attributeDeclarationLines.canFindIndex(current.line))
{
writeToken();
@ -482,6 +475,7 @@ private:
}
else
{
regenLineBreakHintsIfNecessary(index);
if (peekIs(tok!".."))
writeToken();
else if (isBlockHeader(1) && !peekIs(tok!"if"))
@ -489,6 +483,13 @@ private:
writeToken();
write(" ");
}
else if (linebreakHints.canFindIndex(index))
{
pushWrapIndent();
newline();
writeToken();
write(" ");
}
else
{
write(" : ");
@ -563,6 +564,7 @@ private:
}
writeToken();
newline();
linebreakHints = [];
}
}

View file

@ -0,0 +1,12 @@
unittest
{
with (SomeEnum) final switch (value)
{
case a:
aa();
break;
case b:
bb();
break;
}
}

12
tests/issue0108.d Normal file
View file

@ -0,0 +1,12 @@
unittest
{
with (SomeEnum) final switch (value)
{
case a:
aa();
break;
case b:
bb();
break;
}
}

View file

@ -0,0 +1,10 @@
unittest {
with (SomeEnum) final switch (value) {
case a:
aa();
break;
case b:
bb();
break;
}
}