]> git.donarmstrong.com Git - perltidy.git/commitdiff
add alternate fix for b1502
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 23 Dec 2024 23:42:24 +0000 (15:42 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 23 Dec 2024 23:42:24 +0000 (15:42 -0800)
lib/Perl/Tidy/Formatter.pm

index 797987264fb1fcc13b19a1c2f61ec1397fcbb5cd..645cffad80a0bc144e0f6060cbb4d5b20f984a72 100644 (file)
@@ -19792,10 +19792,16 @@ sub setup_new_weld_measurements {
                     my $iline_prev    = $rLL->[$Kprev]->[_LINE_INDEX_];
                     my $rK_range_prev = $rlines->[$iline_prev]->{_rK_range};
                     my ( $Kfirst_prev, $Klast_prev_uu ) = @{$rK_range_prev};
+                    my $nb_count = 0;
                     foreach my $KK ( reverse( $Kfirst_prev .. $Kref - 1 ) ) {
                         next if ( $rLL->[$KK]->[_TYPE_] eq 'b' );
                         $Kref = $KK;
-                        last;
+
+                        # Continue at type 'w' to get previous dash.  Example:
+                        #   -classification => [ qw(
+                        # This fixes b1502.
+                        last if ( $nb_count || $rLL->[$KK]->[_TYPE_] ne 'w' );
+                        $nb_count++;
                     }
                 }
             }
@@ -20712,7 +20718,7 @@ sub weld_nested_quotes {
         # look bad.
         next if ( $Kinner_closing == $Kinner_opening );
 
-        # RULE: Avoid welding under stress. Fixes b1502.
+        # RULE: Avoid welding under stress. This is an alternate b1502 fix.
         my $inner_level = $rLL->[$Kinner_opening]->[_LEVEL_];
         if ( $inner_level >= $high_stress_level ) { next }