On Sun Feb 02 15:32:13 2020, srchulo wrote:
Show quoted text> I like to line up arrows for method calls under each other with a
> final semicolon:
>
> my $var = $object->method1
> ->method2
> ->method3
> ;
>
> However, with --bom on that will become:
>
> my $var = $object->method1
> ->method2
> ->method3;
>
> I wonder if there could be a way to respect the above and leave it? Or
> a way to automatically style it that way? I guess this is really two
> things:
>
> - Lined up arrows
> - Trailing semicolon when method chain is done.
The easiest way to implement this would be to follow the input. This could be done by adding a flag, for example, --break-at-old-semicolon-breakpoints or -bos, which kept any line break before a semicolon. So with -bom -bos the example becomes
my $var = $object->method1
->method2
->method3
;
That's easy to implement, and I tested a patch to do it. A disadvantage is that it puts the entire burden of setting the initial formatting on the user. But it fits well with the -bom parameter, and it is independent of that parameter and might be useful in other situations.
I'll consider adding this flag.
But note that the title of this issue contains "respect indentation', suggesting also that the arrows should remain aligned. That would be very nice to do, but it would be too difficult to implement.
Steve