Fix #246 - Questionable indentation for multiple `with` statements

This commit is contained in:
Laurent Tréguier 2018-10-07 12:13:19 +02:00 committed by The Dlang Bot
parent 494f70b429
commit 886903f8ea
4 changed files with 65 additions and 1 deletions

View File

@ -207,7 +207,7 @@ private:
} }
else if (currentIs(tok!"with")) else if (currentIs(tok!"with"))
{ {
if (indents.length == 0 || indents.top != tok!"switch") if (indents.length == 0 || (indents.top != tok!"switch" && indents.top != tok!"with"))
indents.push(tok!"with"); indents.push(tok!"with");
writeToken(); writeToken();
write(" "); write(" ");

View File

@ -0,0 +1,23 @@
unittest
{
with (Object)
{
// do something
}
with (Object) with (Object)
{
// do something
}
with (Object) with (Object) with (Object)
{
// do something
}
with (Object)
{
with (Object)
{
// do something
}
}
}

24
tests/issue0246.d Normal file
View File

@ -0,0 +1,24 @@
unittest
{
with (Object)
{
// do something
}
with (Object) with (Object)
{
// do something
}
with (Object) with (Object)
with (Object)
{
// do something
}
with (Object)
{
with (Object)
{
// do something
}
}
}

View File

@ -0,0 +1,17 @@
unittest {
with (Object) {
// do something
}
with (Object) with (Object) {
// do something
}
with (Object) with (Object) with (Object) {
// do something
}
with (Object) {
with (Object) {
// do something
}
}
}