This commit is contained in:
Hackerpilot 2015-03-07 15:41:33 -08:00
parent 0a71960d98
commit 39bf1dafb9
3 changed files with 54 additions and 7 deletions

View file

@ -836,6 +836,20 @@ private:
newline();
return;
}
else if (current.type == tok!";")
{
if (peekIs(tok!"}"))
{
writeToken();
newline();
indentLevel = l;
writeToken();
newline();
return;
}
else
goto peek;
}
else if (current.type == tok!"case")
{
writeToken();
@ -848,14 +862,18 @@ private:
writeToken();
write(" ");
}
else if (peekIs(tok!"case", false) || peekIs(tok!"default", false)
|| peekIs(tok!"}", false) || peekIsLabel())
{
indentLevel = l;
formatStep();
}
else
formatStep();
{
peek:
if (peekIs(tok!"case", false) || peekIs(tok!"default", false)
|| peekIs(tok!"}", false) || peekIsLabel())
{
indentLevel = l;
formatStep();
}
else
formatStep();
}
}
indentLevel = l;
assert (current.type == tok!"}");

14
tests/issue0046.d Normal file
View file

@ -0,0 +1,14 @@
class C
{
void func()
{
switch (x)
{
default:
assert(0);
}
}
void main(string[] args)
{}
}

15
tests/issue0046.d.ref Normal file
View file

@ -0,0 +1,15 @@
class C
{
void func()
{
switch (x)
{
default:
assert(0);
}
}
void main(string[] args)
{
}
}