mirror of
https://github.com/dlang-community/dfmt.git
synced 2025-04-25 21:00:03 +03:00
Fix #208
This commit is contained in:
parent
f14c6e1226
commit
382258eb97
4 changed files with 26 additions and 3 deletions
|
@ -949,8 +949,7 @@ private:
|
|||
formatAt();
|
||||
break;
|
||||
case tok!"!":
|
||||
if ((peekIs(tok!"is") || peekIs(tok!"in"))
|
||||
&& !peekBackIsOneOf(false, tok!"(", tok!"="))
|
||||
if ((peekIs(tok!"is") || peekIs(tok!"in")) && !peekBackIsOperator())
|
||||
write(" ");
|
||||
goto case;
|
||||
case tok!"...":
|
||||
|
@ -1488,7 +1487,7 @@ const pure @safe @nogc:
|
|||
return peekImplementation(tokenType, -1, ignoreComments);
|
||||
}
|
||||
|
||||
bool peekBackIsKeyword(bool ignoreComments = true)
|
||||
bool peekBackIsKeyword(bool ignoreComments = true) pure nothrow const @nogc @safe
|
||||
{
|
||||
if (index == 0)
|
||||
return false;
|
||||
|
@ -1503,6 +1502,11 @@ const pure @safe @nogc:
|
|||
return isKeyword(tokens[i].type);
|
||||
}
|
||||
|
||||
bool peekBackIsOperator() pure nothrow const @nogc @safe
|
||||
{
|
||||
return index == 0 ? false : isOperator(tokens[index - 1].type);
|
||||
}
|
||||
|
||||
bool peekBackIsOneOf(bool ignoreComments, IdType[] tokenTypes...)
|
||||
{
|
||||
if (index == 0)
|
||||
|
|
7
tests/allman/issue0208.d.ref
Normal file
7
tests/allman/issue0208.d.ref
Normal file
|
@ -0,0 +1,7 @@
|
|||
unittest
|
||||
{
|
||||
if (a && !is(b == q))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
7
tests/issue0208.d
Normal file
7
tests/issue0208.d
Normal file
|
@ -0,0 +1,7 @@
|
|||
unittest
|
||||
{
|
||||
if (a && !is(b == q))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
5
tests/otbs/issue0208.d.ref
Normal file
5
tests/otbs/issue0208.d.ref
Normal file
|
@ -0,0 +1,5 @@
|
|||
unittest {
|
||||
if (a && !is(b == q)) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue