From: Steve Hancock Date: Thu, 21 Oct 2021 21:34:48 +0000 (-0700) Subject: Fix b1229, very rare instablity with -lp -bbao X-Git-Tag: 20211029~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fef73515086712166f0d9a4695764bd59b17aecb;p=perltidy.git Fix b1229, very rare instablity with -lp -bbao --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 74988faf..4da617f1 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -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" ) ) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 52113923..6d3589c6 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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);