My project (VirtualGL) uses tabs and only tabs, and I try to keep things simple by not aligning continuation lines for conditionals under the open parenthesis. Unfortunately I'm still struggling to figure out the golden set of parameters to reproduce these simple formatting rules using AStyle. Take the following block of code:
> if(!SomeVeryLongFunctionName(someType someVeryLongFunctionArg, > > someType someOtherVeryLongFunctionArg)) > > do_something();
where >
is a tab character, as in the AStyle docs. I thought that the combination of
--style=allman --indent=tab=2 --indent=force-tab=2 --indent-after-parens
would achieve what I want, but unfortunately not. I also tried various combinations of --indent=force-tab-x=2
, --min-conditional-indent
, and --indent-continuation
. If --indent-continuation=0
, it gives me this:
> if(!SomeVeryLongFunctionName(someType someVeryLongFunctionArg, > someType someOtherVeryLongFunctionArg)) > > do_something();
If --indent-continuation=1
(default), it gives me this:
> if(!SomeVeryLongFunctionName(someType someVeryLongFunctionArg, > > > > someType someOtherVeryLongFunctionArg)) > > do_something();
Either I'm missing something, or something isn't working as advertised.
Clarification: minimal reproduction steps:
Create
test.c
with:Attempt to reformat using
Expected result:
Actual result:
Just a sidenote. Though not what you expected, the actual result reads much clearer: the depending statement better stands out from the continued condition line.
Last edit: w-peuker 2018-03-19
Perhaps so, but the core issue is that I currently cannot trust the behavior of the tool, because it isn't behaving in a deterministic manner. I need to understand what it's trying to do and why, or else I will not use it.
Add the option --indent-continuation=0.
You don't need the option --indent=tab=2. It can be removed.
That doesn't work either. It produces this:
That is, the continuation of the function arguments are not indented at all. That's really the source of my consternation.
--indent-continuation=0
doesn't indent the continued arguments, and--indent-continuation=1
indents them with two tabs instead of one. I need a way to indent them with just one tab.It idents once for each open paren.
If there were one paren, it would indent once. If two it indents twice.
There seems to be a problem where it doubles the indent instead of adding one.
I will check this before the next release.
I have the same problem with the double indent instead of adding one. Is there is fix or workaround availabe by now?
Sorry, but there have been no changes. You might try thr options max-continuation-indent and
min-conditional-indent to see if that helps.