Format multiline arrays first
This commit is contained in:
parent
995c21ab87
commit
96b27011f4
|
@ -612,22 +612,7 @@ private:
|
||||||
immutable bool arrayInitializerStart = p == tok!"["
|
immutable bool arrayInitializerStart = p == tok!"["
|
||||||
&& astInformation.arrayStartLocations.canFindIndex(tokens[index - 1].index);
|
&& astInformation.arrayStartLocations.canFindIndex(tokens[index - 1].index);
|
||||||
|
|
||||||
if (p == tok!"[" && config.dfmt_keep_line_breaks == OptionalBoolean.t)
|
if (arrayInitializerStart && isMultilineAt(index - 1))
|
||||||
{
|
|
||||||
IndentStack.Details detail;
|
|
||||||
|
|
||||||
detail.wrap = false;
|
|
||||||
detail.temp = false;
|
|
||||||
detail.breakEveryItem = false;
|
|
||||||
detail.mini = tokens[index].line == tokens[index - 1].line;
|
|
||||||
|
|
||||||
indents.push(tok!"]", detail);
|
|
||||||
if (!detail.mini)
|
|
||||||
{
|
|
||||||
newline();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (arrayInitializerStart && isMultilineAt(index - 1))
|
|
||||||
{
|
{
|
||||||
if (peekBack2Is(tok!"(")) {
|
if (peekBack2Is(tok!"(")) {
|
||||||
indents.pop();
|
indents.pop();
|
||||||
|
@ -653,6 +638,21 @@ private:
|
||||||
linebreakHints = chooseLineBreakTokens(index, tokens[index .. j],
|
linebreakHints = chooseLineBreakTokens(index, tokens[index .. j],
|
||||||
depths[index .. j], config, currentLineLength, indentLevel);
|
depths[index .. j], config, currentLineLength, indentLevel);
|
||||||
}
|
}
|
||||||
|
else if (p == tok!"[" && config.dfmt_keep_line_breaks == OptionalBoolean.t)
|
||||||
|
{
|
||||||
|
IndentStack.Details detail;
|
||||||
|
|
||||||
|
detail.wrap = false;
|
||||||
|
detail.temp = false;
|
||||||
|
detail.breakEveryItem = false;
|
||||||
|
detail.mini = tokens[index].line == tokens[index - 1].line;
|
||||||
|
|
||||||
|
indents.push(tok!"]", detail);
|
||||||
|
if (!detail.mini)
|
||||||
|
{
|
||||||
|
newline();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (arrayInitializerStart)
|
else if (arrayInitializerStart)
|
||||||
{
|
{
|
||||||
// This is a short (non-breaking) array/AA value
|
// This is a short (non-breaking) array/AA value
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
functionLengthDoesMatter([
|
||||||
|
firstFunctionInChain("A").seconFunctionInChain("B").value,
|
||||||
|
firstFunctionInChain("A").seconFunctionInChain("B").value
|
||||||
|
]);
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
functionLengthDoesMatter([
|
||||||
|
firstFunctionInChain("A").seconFunctionInChain("B").value,
|
||||||
|
firstFunctionInChain("A").seconFunctionInChain("B").value
|
||||||
|
]);
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
--keep_line_breaks=true
|
|
@ -0,0 +1,6 @@
|
||||||
|
unittest {
|
||||||
|
functionLengthDoesMatter([
|
||||||
|
firstFunctionInChain("A").seconFunctionInChain("B").value,
|
||||||
|
firstFunctionInChain("A").seconFunctionInChain("B").value
|
||||||
|
]);
|
||||||
|
}
|
Loading…
Reference in New Issue