From: Steve Hancock Date: Sat, 17 Oct 2020 20:36:59 +0000 (-0700) Subject: modify rule for welding subs within subs X-Git-Tag: 20201001.03~70 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=27beff416b959f95c6ad25067e593b13151e457b;p=perltidy.git modify rule for welding subs within subs --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 50817341..af58bdfb 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -5915,8 +5915,13 @@ sub find_nested_pairs { && $rLL->[$K_outer_opening]->[_TOKEN_] eq '(' ) # anonymous sub + prototype or sig: )->then( sub ($code) { + # ... but it seems best not to stack two structural blocks, like + # this + # sub make_anon_with_my_sub { sub { + # because it probably hides the structure a little too much. || ( $rLL->[$K_inner_opening]->[_BLOCK_TYPE_] eq 'sub' - && $rLL->[$Kn_first]->[_TOKEN_] eq 'sub' ) + && $rLL->[$Kn_first]->[_TOKEN_] eq 'sub' + && !$rLL->[$K_outer_opening]->[_BLOCK_TYPE_] ) ) { push @nested_pairs,