mirror of
https://github.com/dlang-community/dfmt.git
synced 2025-04-25 21:00:03 +03:00
Fix #108
This commit is contained in:
parent
efc9d72c95
commit
83072689d1
4 changed files with 46 additions and 10 deletions
22
src/dfmt.d
22
src/dfmt.d
|
@ -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 = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
12
tests/allman/issue0108.d.ref
Normal file
12
tests/allman/issue0108.d.ref
Normal 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
12
tests/issue0108.d
Normal file
|
@ -0,0 +1,12 @@
|
|||
unittest
|
||||
{
|
||||
with (SomeEnum) final switch (value)
|
||||
{
|
||||
case a:
|
||||
aa();
|
||||
break;
|
||||
case b:
|
||||
bb();
|
||||
break;
|
||||
}
|
||||
}
|
10
tests/otbs/issue0108.d.ref
Normal file
10
tests/otbs/issue0108.d.ref
Normal file
|
@ -0,0 +1,10 @@
|
|||
unittest {
|
||||
with (SomeEnum) final switch (value) {
|
||||
case a:
|
||||
aa();
|
||||
break;
|
||||
case b:
|
||||
bb();
|
||||
break;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue