So we have some issues with how we handle indentation and closing parens under certain weird cases. We shouldn't fix the current set of options to make it "work" with what we want. Instead we should create a new option that indents and closes parens with the wanted behavior. Then we enable the option in our configs separately.
The rules are as follows
While having open parens, doing line break will only result in 1 indentation per line break.
Closing parens that are not on the same line, should be at the original indentation level of the line with the open parens.
The line with the closing parens, should have same amount of closing parens as the original line with the open parens had.
Let us demostrate this with some example cases.
Input
bool success(GenerateSecondaryUVSet(test(
&mesh.vertices[0].x, mesh.vertices.size(),
&triUV[0].x, &triList[0], triSrcPoly.size() ? &triSrcPoly[0] : 0, triCount,
&outUV[0].x, param, errorBuffer, bufferSize
)
));
Output
bool success(GenerateSecondaryUVSet(test(
&mesh.vertices[0].x, mesh.vertices.size(),
&triUV[0].x, &triList[0], triSrcPoly.size() ? &triSrcPoly[0] : 0, triCount,
&outUV[0].x, param, errorBuffer, bufferSize
)));
In this case the first line bool success(GenerateSecondaryUVSet(test(
contains 3 open parens. This means that the line that contains the closing parens should also have 3 closing parens. As shown in the output block in the last line containing )));
.
Input
int m = aaaaaaaaaaabaaaaaaaaaa(caaaaaaaaaa(
eaaaaaaaaaa(gaaaaaaaaaaa(haaaaaaaaaaaaa(
iaaaaaaaaaaaaaaaaaaaaaa(kaaaaaaaaaaaaaaaaaaaa)
)
)
)
)
);
Output
int m = aaaaaaaaaaabaaaaaaaaaa(caaaaaaaaaa(
eaaaaaaaaaa(gaaaaaaaaaaa(haaaaaaaaaaaaa(
iaaaaaaaaaaaaaaaaaaaaaa(kaaaaaaaaaaaaaaaaaaaa)
)))
));
Here we have a case where there is multiple levels of indentation, and the rules of having closing parens aligned is still preserved. So the first line has 2 open parens int m = aaaaaaaaaaabaaaaaaaaaa(caaaaaaaaaa(
which means that the ending line should have 2 closing parens ));
.
Input
int m = aaaaaaaaaaabaaaaaaaaaa(caaaaaaaaaa(
eaaaaaaaaaa(gaaaaaaaaaaa(haaaaaaaaaaaaa(
iaaaaaaaaaaaaaaaaaaaaaa(kaaaaaaaaaaaaaaaaaaaa)
))
))
);
Output
int m = aaaaaaaaaaabaaaaaaaaaa(caaaaaaaaaa(
eaaaaaaaaaa(gaaaaaaaaaaa(haaaaaaaaaaaaa(
iaaaaaaaaaaaaaaaaaaaaaa(kaaaaaaaaaaaaaaaaaaaa)
)))
));
Another case like 2.1 just with slightly different input. But the result is the same.
Input
int m = aaaaaaaaaaabaaaaaaaaaa(
caaaaaaaaaa(
eaaaaaaaaaa(
gaaaaaaaaaaa(
haaaaaaaaaaaaa(
iaaaaaaaaaaaaaaaaaaaaaa(kaaaaaaaaaaaaaaaaaaaa)
)
)
)
)
);
Output
int m = aaaaaaaaaaabaaaaaaaaaa(
caaaaaaaaaa(
eaaaaaaaaaa(
gaaaaaaaaaaa(
haaaaaaaaaaaaa(
iaaaaaaaaaaaaaaaaaaaaaa(kaaaaaaaaaaaaaaaaaaaa)
)
)
)
)
);
This is a case where the input already follows the mentioned rules. But it is actually formated differently. It is still very much legal code.