Prefer breaking on ternary operators

This commit is contained in:
Hackerpilot 2016-01-26 13:05:59 -08:00
parent c1f189b124
commit 845358bb61
3 changed files with 6 additions and 6 deletions

View File

@ -1320,8 +1320,8 @@ private:
} }
immutable l = indents.indentToMostRecent(tok!"switch"); immutable l = indents.indentToMostRecent(tok!"switch");
if (l != -1) if (l != -1)
indentLevel = config.dfmt_align_switch_statements indentLevel = config.dfmt_align_switch_statements == OptionalBoolean.t
== OptionalBoolean.t ? l : indents.indentLevel; ? l : indents.indentLevel;
} }
else if (currentIs(tok!")")) else if (currentIs(tok!")"))
{ {

View File

@ -183,8 +183,8 @@ private:
int parenCount; int parenCount;
foreach (i; 0 .. j) foreach (i; 0 .. j)
{ {
immutable int pc = (arr[i] == tok!"!" || arr[i] == tok!"(" || arr[i] == tok!")") ? parenCount immutable int pc = (arr[i] == tok!"!" || arr[i] == tok!"(" || arr[i] == tok!")") ? parenCount + 1
+ 1 : parenCount; : parenCount;
if ((isWrapIndent(arr[i]) || arr[i] == tok!"(") && parenCount > 1) if ((isWrapIndent(arr[i]) || arr[i] == tok!"(") && parenCount > 1)
{ {
parenCount = pc; parenCount = pc;

View File

@ -133,12 +133,13 @@ int breakCost(IdType p, IdType c) pure nothrow @safe @nogc
case tok!"||": case tok!"||":
case tok!"&&": case tok!"&&":
case tok!",": case tok!",":
case tok!":":
case tok!"?":
return 0; return 0;
case tok!"(": case tok!"(":
return 60; return 60;
case tok!"[": case tok!"[":
return 300; return 300;
case tok!":":
case tok!";": case tok!";":
case tok!"^^": case tok!"^^":
case tok!"^=": case tok!"^=":
@ -169,7 +170,6 @@ int breakCost(IdType p, IdType c) pure nothrow @safe @nogc
case tok!"!=": case tok!"!=":
case tok!"!>=": case tok!"!>=":
case tok!"!>": case tok!"!>":
case tok!"?":
case tok!"/=": case tok!"/=":
case tok!"/": case tok!"/":
case tok!"..": case tok!"..":