]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix problem with combination -lp and -wbb='='
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 7 Mar 2021 13:49:10 +0000 (05:49 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 7 Mar 2021 13:49:10 +0000 (05:49 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 7585b38354c10ac6b76ff90de3bcd340cd2c1e41..444d2175e196fea7b69d7337a388bd851e9a7818 100644 (file)
@@ -10842,6 +10842,10 @@ sub compare_indentation_levels {
 
         return unless defined $i && $i >= 0;
 
+        # Back up at a blank in case we need an = break.
+        # This is a backup fix for cases like b932.
+        if ( $i > 0 && $types_to_go[$i] eq 'b' ) { $i-- }
+
         # no breaks between welded tokens
         return if ( $self->weld_len_right_to_go($i) );
 
@@ -15496,8 +15500,16 @@ sub set_continuation_breaks {
                                 my $test2 = $nesting_depth_to_go[$i_start_2];
                                 if ( $test2 == $test1 ) {
 
-                                    $self->set_forced_breakpoint(
-                                        $i_start_2 - 1 );
+                                    # Back up at a blank (fixes case b932)
+                                    my $ibr = $i_start_2 - 1;
+                                    if (   $ibr > 0
+                                        && $types_to_go[$ibr] eq 'b' )
+                                    {
+                                        $ibr--;
+                                    }
+
+                                    $self->set_forced_breakpoint($ibr);
+
                                 }
                             } ## end if ( defined($i_start_2...))
                         } ## end if ( defined($item) )
index 0c469274f441798d763b19c2388f767fd98b070b..348eaaac80030786f0f0c11cf597e01985e630da 100644 (file)
@@ -2,6 +2,35 @@
 
 =over 4
 
+=item B<Fix problem with combination -lp and -wbb='='>
+
+Random testing produced case b932 in which the combination -lp and -wbb='='
+was not stable. 
+
+File 'b932.par' is:
+
+    --line-up-parentheses
+    --maximum-line-length=51
+    --want-break-before='='
+
+File 'b932.in' in the desired state is:
+
+    my @parts
+      = decompose( '(\s+|/|\!|=)',
+                   $line, undef, 1, undef, '["\']' );
+
+The alternate state is
+
+    my @parts = decompose( '(\s+|/|\!|=)',
+                     $line, undef, 1, undef, '["\']' );
+
+The problem was that the -lp code which set a line break at the equals did not
+check the -wba flag setting.
+
+This update fixes case b932.
+
+7 Mar 2021.
+
 =item B<Fix edge formatting cases with parameter -bbx=2>
 
 Random testing produced some cases where formatting with parameters of the form
@@ -11,7 +40,7 @@ list for this particular flag to be a list with at least one non-terminal
 line-ending comma.  This insures that the list will remain broken on subsequent
 iterations.  This fixes cases b789 and b938.
 
-6 Mar 2021.
+6 Mar 2021, 360d669.
 
 =item B<Add flag -fpva, --function-paren-vertical-alignment>