]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix b1229, very rare instablity with -lp -bbao
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 21 Oct 2021 21:34:48 +0000 (14:34 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 21 Oct 2021 21:34:48 +0000 (14:34 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 74988faff6c3faf2dfcbc327ef3779ef3392ddce..4da617f1bdd726bc64a457581927ea359683d2c3 100644 (file)
@@ -7746,6 +7746,27 @@ $obj= {foo => sub { "bar" ; }
 --maximum-line-length=29
 --want-break-before='='
 
+==> b1229.in <==
+# S1
+              $n
+                     += ( $b
+                        = sysread( $data, ${*$data}, $blksize, $l )
+                     );
+
+# S2
+              $n += (
+                        $b
+                        = sysread( $data, ${*$data}, $blksize, $l )
+              );
+
+==> b1229.par <==
+--break-before-all-operators
+--continuation-indentation=7
+--extended-continuation-indentation
+--indent-columns=7
+--line-up-parentheses
+--maximum-line-length=67
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
index 521139232f2e0d2c2f44bcf7802fb6650d56edde..6d3589c6e5f3b204ab8497096f28993bbcc7cce5 100644 (file)
@@ -19441,7 +19441,12 @@ sub get_available_spaces_to_go {
 
                 # find the position if we break at the '='
                 my $i_test = $last_equals;
-                if ( $types_to_go[ $i_test + 1 ] eq 'b' ) { $i_test++ }
+
+                # Fix for issue b1229, check for break before
+                if ( $want_break_before{ $types_to_go[$i_test] } ) {
+                    if ( $i_test > 0 ) { $i_test-- }
+                }
+                elsif ( $types_to_go[ $i_test + 1 ] eq 'b' ) { $i_test++ }
 
                 # TESTING
                 ##my $too_close = ($i_test==$max_index_to_go-1);