]> git.donarmstrong.com Git - perltidy.git/commitdiff
modify rule for welding subs within subs
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 17 Oct 2020 20:36:59 +0000 (13:36 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 17 Oct 2020 20:36:59 +0000 (13:36 -0700)
lib/Perl/Tidy/Formatter.pm

index 508173418cf208aee86ad0567a2e4d2770a88696..af58bdfbe557608b67ca0b15504b4f930d38e01f 100644 (file)
@@ -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,