mirror of
https://github.com/dlang-community/dfmt.git
synced 2025-04-25 21:00:03 +03:00
Fix #46
This commit is contained in:
parent
0a71960d98
commit
39bf1dafb9
3 changed files with 54 additions and 7 deletions
32
src/dfmt.d
32
src/dfmt.d
|
@ -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
14
tests/issue0046.d
Normal 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
15
tests/issue0046.d.ref
Normal file
|
@ -0,0 +1,15 @@
|
|||
class C
|
||||
{
|
||||
void func()
|
||||
{
|
||||
switch (x)
|
||||
{
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
void main(string[] args)
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue