From: Steve Hancock Date: Fri, 8 Oct 2021 22:16:08 +0000 (-0700) Subject: fix issue b1211, rare formatting instability X-Git-Tag: 20211029~30 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=61ef40ba033c71097a08c7cac45c4fccee4969d4;p=perltidy.git fix issue b1211, rare formatting instability --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 8722f6df..cebf06fc 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7456,6 +7456,33 @@ $bc[ --maximum-line-length=34 --variable-maximum-line-length +==> b1211.in <== +# S1 + my$d= + \substr( + (state$tb= + $thunderbirds[$x]), + $x,1 + ); + +# S2 + my$d= + \substr( + ( + state$tb=$thunderbirds[ + $x] + ), + $x,1 + ); + + +==> b1211.par <== +--noadd-whitespace +--ignore-old-breakpoints +--indent-columns=1 +--line-up-parentheses +--maximum-line-length=37 + ==> b1212.in <== # S1 my $line_count diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index a9694952..4eeca314 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -17910,7 +17910,8 @@ BEGIN { my @q = qw(k w i Z ->); @is_kwiZ{@q} = (1) x scalar(@q); - @q = qw<( [ { L R } ] ) b>; + # added = for b1211 + @q = qw<( [ { L R } ] ) = b>; push @q, ','; @is_key_type{@q} = (1) x scalar(@q); } @@ -17959,7 +17960,12 @@ sub find_token_starting_list { # previous loop: for ( my $j = $im1 ; $j >= 0 ; $j-- ) { for ( my $j = $iprev_nb ; $j >= 0 ; $j-- ) { ##last if ( $types_to_go[$j] =~ /^[\(\[\{L\}\]\)Rb,]$/ ); - last if ( $is_key_type{ $types_to_go[$j] } ); + if ( $is_key_type{ $types_to_go[$j] } ) { + + # fix for b1211 + if ( $types_to_go[$j] eq '=' ) { $i_opening_minus = $j } + last; + } $i_opening_minus = $j; } if ( $types_to_go[$i_opening_minus] eq 'b' ) { $i_opening_minus++ } @@ -19403,15 +19409,12 @@ sub get_available_spaces_to_go { if ( $gnu_sequence_number != $seqno || $i > $max_gnu_item_index ) { + # non-fatal, keep going except in DEVEL_MODE if (DEVEL_MODE) { Fault(<get_level(); - my $ci_level = $gnu_item_list[$i_debug]->get_ci_level(); - my $old_level = $gnu_item_list[$i]->get_level(); - my $old_ci_level = $gnu_item_list[$i]->get_ci_level(); + # non-fatal, keep going except in DEVEL_MODE if (DEVEL_MODE) { + my $level = $gnu_item_list[$i_debug]->get_level(); + my $ci_level = $gnu_item_list[$i_debug]->get_ci_level(); + my $old_level = $gnu_item_list[$i]->get_level(); + my $old_ci_level = $gnu_item_list[$i]->get_ci_level(); Fault(<