Skip Menu |
 

This queue is for tickets about the Perl-Tidy CPAN distribution.

Report information
The Basics
Id: 131644
Status: open
Priority: 0/
Queue: Perl-Tidy

People
Owner: Nobody in particular
Requestors: violapiratejunky [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: --break-at-old-method-breakpoints respect indentation
Download (untitled) / with headers
text/plain 494b
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.
Download (untitled) / with headers
text/plain 1.3k
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
Download (untitled) / with headers
text/plain 1.6k
On Sun Feb 02 20:18:38 2020, SHANCOCK wrote: Show quoted text
> On Sun Feb 02 15:32:13 2020, srchulo wrote:
> > 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
Thanks for the quick response! It's a shame that aligning the arrows is difficult. I assume it's also difficult to detect this case and leave it to the user, not just to have perltidy automatically do it?
Download (untitled) / with headers
text/plain 532b
It isn't possible to replicate existing indentation unless formatting is completely turned off with format skipping markers: #<<< my $var = $object->method1 ->method2 ->method3 ; #>>> which is a rather drastic solution. But note that pointers would be aligned if there were a break before the first method call: my $var = $object ->method1 ->method2 ->method3 ; I'll think about it, but right now I don't see an easy way to implement this alignment automatically. Steve


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.